Fugitive – a Git plugin for Vim

May 29, 2011

Do you like Git?

Do you like Vim ?

Then you will like “Fugitive” !

Fugitive is a Vim plugin that empowers you to manage many git commands from Vim.

Created by: Tim Pope

You can download Fugitive here:


Extract it in the directory:


or ~\vimfiles on Windows.


Go to the directory of your Git repository checkout,
for example, if working on ITK do:

cd ~/src/ITK

gvim  CMakeLists.txt

Look at the equivalent of “git blame” by doing


It will produce the following screen:

the command


will produce the following screen:

If, you start with simply “gvim” (with an empty file) and use the command:


you get to see first the branch where you are

if you hit ENTER on that line, you get the most recent commit in that branch

and if you hit ENTER again you get to see the diffs of that commit

moving now the cursor to one of the “diff” lines in green, and hitting ENTER,
will open the relevant file in diff mode with a vertically split window:

if you use the “:ls” command, you will notice that the files
are actually listed from their respective commits.

 If you open a file, make some changes to it, and save those changes,
you can see the git differences by using the command:



You can also run from Vim any git command by using:

:Git  [args]

it will be equivalent to doing

:!git [args]

for example, you could do:

:Git   commit   –amend

You can grep the content of the repository with the command:



and one of the most beautiful features…

If your remote is in Github, and you open a file in your local repository,
for example:

gvim CMakeLists.txt

then from gvim you can type:


it will open that same file in your Web browser (in a new tab)
by using the navigation in the github web page

 You could qualify it by selecting a filename, for example

:Gbrowse  Modules/Core/Common/include/itkImage.h



For a full description of the many features,
read the “fugitive.txt” file that gets installed in



Happy Viming !

3 comments to Fugitive – a Git plugin for Vim

  1. Be careful: using vim in this way may be considered illegal in certain jurisdictions around the world…

Leave a Reply