Convert Figma logo to code with AI

tpope logovim-fugitive

fugitive.vim: A Git wrapper so awesome, it should be illegal

20,879
1,027
20,879
81

Top Related Projects

34,999

:hibiscus: Minimalist Vim Plugin Manager

A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks.

2,166

An efficient fuzzy finder that helps to locate files, buffers, mrus, gtags, etc. on the fly for both vim and neovim.

19,922

A tree explorer plugin for vim.

13,785

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support

24,811

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.

Quick Overview

Vim-fugitive is a powerful Git wrapper for Vim, created by Tim Pope. It allows users to interact with Git repositories directly from within Vim, providing a seamless integration of Git commands and functionality into the Vim editing environment.

Pros

  • Seamless integration of Git commands within Vim
  • Enhances productivity by eliminating the need to switch between Vim and the command line
  • Provides advanced Git features like interactive staging, blame, and diff viewing
  • Regularly updated and maintained by a respected Vim plugin developer

Cons

  • Steep learning curve for users new to Vim or Git
  • Some commands may be less intuitive compared to command-line Git
  • Requires a solid understanding of both Vim and Git to fully utilize its features
  • May conflict with other Git-related Vim plugins

Code Examples

  1. Viewing Git status:
:G

This opens a split window showing the Git status, similar to git status.

  1. Staging changes:
:G add %

This stages the current file, equivalent to git add <current_file>.

  1. Committing changes:
:G commit

This opens a split window for writing a commit message.

  1. Viewing diff:
:Gdiff

This shows the diff for the current file in a split window.

Getting Started

  1. Install vim-fugitive using your preferred Vim plugin manager. For example, with vim-plug:
" Add to your .vimrc or init.vim
call plug#begin()
Plug 'tpope/vim-fugitive'
call plug#end()
  1. Run :PlugInstall in Vim to install the plugin.

  2. Basic usage:

    • Use :G to open the Git status window
    • Navigate through the status window and press - to stage/unstage files
    • Use :G commit to commit changes
    • Explore other commands like :G blame, :G diff, :G log
  3. Refer to the plugin's documentation (:help fugitive) for more advanced usage and commands.

Competitor Comparisons

34,999

:hibiscus: Minimalist Vim Plugin Manager

Pros of vim-plug

  • Simpler and more focused: vim-plug is specifically designed for plugin management
  • Faster installation and updates: uses parallel downloads for better performance
  • Minimalist syntax: easier to configure and manage plugins

Cons of vim-plug

  • Limited scope: doesn't provide Git integration or version control features
  • Less versatile: focused solely on plugin management, unlike Fugitive's broader functionality

Code comparison

vim-plug:

call plug#begin()
Plug 'tpope/vim-fugitive'
Plug 'junegunn/fzf.vim'
call plug#end()

vim-fugitive:

:Git add %
:Git commit -m "Commit message"
:Git push

Key differences

  • Purpose: vim-plug is a plugin manager, while Fugitive is a Git wrapper
  • Functionality: Fugitive offers extensive Git integration, vim-plug focuses on plugin installation
  • User experience: vim-plug simplifies plugin management, Fugitive enhances Git workflow within Vim

Use cases

  • vim-plug: Ideal for users who want a straightforward way to manage Vim plugins
  • Fugitive: Best for developers who frequently work with Git and want seamless integration in Vim

Community and support

Both projects have active communities and are well-maintained, but Fugitive has a larger user base due to its broader functionality and longer history in the Vim ecosystem.

A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks.

Pros of vim-gitgutter

  • Real-time git diff information displayed in the sign column
  • Lightweight and focused on a specific task (showing git diff)
  • Minimal setup required, works out of the box with default settings

Cons of vim-gitgutter

  • Limited to showing git diff information, lacks broader git integration
  • Doesn't provide git commands or operations within Vim
  • May have performance impact on large files or repositories

Code comparison

vim-gitgutter:

let g:gitgutter_sign_added = '+'
let g:gitgutter_sign_modified = '~'
let g:gitgutter_sign_removed = '-'

vim-fugitive:

:Git blame
:Gdiff
:Gstatus

Summary

vim-gitgutter is a lightweight plugin focused on displaying git diff information in real-time within Vim's sign column. It's easy to set up and provides immediate visual feedback on file changes.

vim-fugitive, on the other hand, is a comprehensive Git wrapper for Vim, offering a wide range of Git operations and commands directly within the editor. It provides deeper integration with Git but may have a steeper learning curve.

Choose vim-gitgutter for quick, visual git diff information, or vim-fugitive for a more complete Git integration within Vim.

2,166

An efficient fuzzy finder that helps to locate files, buffers, mrus, gtags, etc. on the fly for both vim and neovim.

Pros of LeaderF

  • Faster and more efficient fuzzy finding capabilities
  • More extensive file and buffer management features
  • Highly customizable with various search modes and extensions

Cons of LeaderF

  • Steeper learning curve due to more complex configuration options
  • Requires Python support in Vim, which may not be available in all environments
  • Less focused on Git integration compared to Fugitive

Code Comparison

LeaderF (fuzzy finding):

" Search for files
:Leaderf file

" Search for buffers
:Leaderf buffer

" Search for functions
:Leaderf function

Fugitive (Git operations):

" Git status
:Gstatus

" Git commit
:Gcommit

" Git blame
:Gblame

LeaderF is primarily a fuzzy finder and file management tool, while Fugitive is focused on Git integration within Vim. LeaderF offers more advanced search capabilities and file navigation, but requires additional setup and Python support. Fugitive provides seamless Git operations directly from Vim, making it easier to work with version control. The choice between the two depends on whether you prioritize advanced file management or Git integration in your workflow.

19,922

A tree explorer plugin for vim.

Pros of NERDTree

  • Provides a visual file system explorer within Vim
  • Allows easy navigation and manipulation of directory structures
  • Supports bookmarks and custom mappings for quick access to frequently used directories

Cons of NERDTree

  • Can be resource-intensive for large projects
  • May clutter the Vim interface, especially on smaller screens
  • Requires additional setup and configuration for optimal use

Code Comparison

NERDTree (file navigation):

:NERDTree
:NERDTreeToggle
:NERDTreeFind

Vim-fugitive (Git operations):

:Git add %
:Git commit
:Git push

Key Differences

  • NERDTree focuses on file system navigation and management
  • Vim-fugitive is primarily for Git integration within Vim
  • NERDTree provides a visual interface, while Vim-fugitive operates through commands
  • Vim-fugitive offers more comprehensive version control features
  • NERDTree is more suitable for users who prefer visual file browsing

Use Cases

NERDTree:

  • Exploring project structures
  • Quick file creation and deletion
  • Managing multiple files across directories

Vim-fugitive:

  • Performing Git operations without leaving Vim
  • Viewing file changes and commit history
  • Resolving merge conflicts

Both plugins enhance Vim's functionality but serve different purposes. NERDTree improves file navigation, while Vim-fugitive streamlines Git workflows within the editor.

13,785

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support

Pros of ALE

  • Provides real-time linting and fixing capabilities for multiple languages
  • Offers asynchronous execution, improving performance and responsiveness
  • Integrates with various external tools and linters out of the box

Cons of ALE

  • Can be more resource-intensive due to its extensive feature set
  • May require additional configuration for optimal performance
  • Potential for conflicts with other plugins or custom setups

Code Comparison

ALE (example configuration):

let g:ale_linters = {
\   'javascript': ['eslint'],
\   'python': ['flake8'],
\}
let g:ale_fixers = {
\   '*': ['remove_trailing_lines', 'trim_whitespace'],
\   'javascript': ['eslint'],
\}

Vim-fugitive (example usage):

:Git add %
:Git commit -m "Commit message"
:Git push
:Gblame
:Gdiff

While ALE focuses on linting and fixing code, Vim-fugitive is primarily a Git wrapper for Vim. ALE enhances the coding experience with real-time feedback, while Vim-fugitive streamlines Git operations within the editor. The choice between them depends on whether you prioritize code quality tools or Git integration in your workflow.

24,811

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.

Pros of coc.nvim

  • Provides intelligent code completion and language server protocol (LSP) support
  • Offers a wide range of extensions for various programming languages and tools
  • Supports asynchronous operations, resulting in better performance

Cons of coc.nvim

  • Requires Node.js as a dependency, which may not be ideal for all users
  • Has a steeper learning curve compared to vim-fugitive's focused Git integration
  • May consume more system resources due to its extensive features

Code Comparison

vim-fugitive (Git status command):

:Gstatus

coc.nvim (LSP-based code action):

:CocAction

While vim-fugitive focuses on Git integration with simple commands, coc.nvim provides a more comprehensive development environment with intelligent features. vim-fugitive is lightweight and specifically tailored for Git operations, whereas coc.nvim offers a broader range of functionality at the cost of increased complexity and resource usage.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

fugitive.vim

Fugitive is the premier Vim plugin for Git. Or maybe it's the premier Git plugin for Vim? Either way, it's "so awesome, it should be illegal". That's why it's called Fugitive.

The crown jewel of Fugitive is :Git (or just :G), which calls any arbitrary Git command. If you know how to use Git at the command line, you know how to use :Git. It's vaguely akin to :!git but with numerous improvements:

  • The default behavior is to directly echo the command's output. Quiet commands like :Git add avoid the dreaded "Press ENTER or type command to continue" prompt.
  • :Git commit, :Git rebase -i, and other commands that invoke an editor do their editing in the current Vim instance.
  • :Git diff, :Git log, and other verbose, paginated commands have their output loaded into a temporary buffer. Force this behavior for any command with :Git --paginate or :Git -p.
  • :Git blame uses a temporary buffer with maps for additional triage. Press enter on a line to view the commit where the line changed, or g? to see other available maps. Omit the filename argument and the currently edited file will be blamed in a vertical, scroll-bound split.
  • :Git mergetool and :Git difftool load their changesets into the quickfix list.
  • Called with no arguments, :Git opens a summary window with dirty files and unpushed and unpulled commits. Press g? to bring up a list of maps for numerous operations including diffing, staging, committing, rebasing, and stashing. (This is the successor to the old :Gstatus.)
  • This command (along with all other commands) always uses the current buffer's repository, so you don't need to worry about the current working directory.

Additional commands are provided for higher level operations:

  • View any blob, tree, commit, or tag in the repository with :Gedit (and :Gsplit, etc.). For example, :Gedit HEAD~3:% loads the current file as it existed 3 commits ago.
  • :Gdiffsplit (or :Gvdiffsplit) brings up the staged version of the file side by side with the working tree version. Use Vim's diff handling capabilities to apply changes to the staged version, and write that buffer to stage the changes. You can also give an arbitrary :Gedit argument to diff against older versions of the file.
  • :Gread is a variant of git checkout -- filename that operates on the buffer rather than the file itself. This means you can use u to undo it and you never get any warnings about the file changing outside Vim.
  • :Gwrite writes to both the work tree and index versions of a file, making it like git add when called from a work tree file and like git checkout when called from the index or a blob in history.
  • :Ggrep is :grep for git grep. :Glgrep is :lgrep for the same.
  • :GMove does a git mv on the current file and changes the buffer name to match. :GRename does the same with a destination filename relative to the current file's directory.
  • :GDelete does a git rm on the current file and simultaneously deletes the buffer. :GRemove does the same but leaves the (now empty) buffer open.
  • :GBrowse to open the current file on the web front-end of your favorite hosting provider, with optional line range (try it in visual mode). Plugins are available for popular providers such as GitHub, GitLab, Bitbucket, Gitee, Pagure, Phabricator, Azure DevOps, and sourcehut.

Add %{FugitiveStatusline()} to 'statusline' to get an indicator with the current branch in your statusline.

For more information, see :help fugitive.

Screencasts

Installation

Install using your favorite package manager, or use Vim's built-in package support:

mkdir -p ~/.vim/pack/tpope/start
cd ~/.vim/pack/tpope/start
git clone https://tpope.io/vim/fugitive.git
vim -u NONE -c "helptags fugitive/doc" -c q

FAQ

What happened to the dispatch.vim backed asynchronous :Gpush and :Gfetch?

This behavior was divisive, confusing, and complicated inputting passwords, so it was removed. Use :Git! push to use Fugitive's own asynchronous execution, or retroactively make :Git push asynchronous by pressing CTRL-D.

Why am I getting core.worktree is required when using an external Git dir?

Git generally sets core.worktree for you automatically when necessary, but if you're doing something weird, or using a third-party tool that does something weird, you may need to set it manually:

git config core.worktree "$PWD"

This may be necessary even when simple git commands seem to work fine without it.

So I have a symlink and...

Stop. Just stop. If Git won't deal with your symlink, then Fugitive won't either. Consider using a plugin that resolves symlinks, or even better, using fewer symlinks.

Self-Promotion

Like fugitive.vim? Follow the repository on GitHub and vote for it on vim.org. And if you're feeling especially charitable, follow tpope on Twitter and GitHub.

License

Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. See :help license.