Invoke vim in diff mode on git changes, in a navigable, editable way
Clone or download
Philip Zeyliger
Philip Zeyliger Adding installation note.
Latest commit 3d59c0f Nov 22, 2012
Type Name Latest commit message Commit time
Failed to load latest commit information. Adding installation note. Nov 22, 2012
git-vimdiff Bugfix. Nov 22, 2012


Invokes vim in diff mode on your git changes, with capability to navigate across pairs of files. Typically, the right hand is editable.

Installation & Usage

  $ curl > ~/bin/git-vimdiff
  $ chmod ugo+x ~/bin/git-vimdiff
  $ ~/bin/git-vimdiff [options for git diff]

I commonly use git-vimdiff --cached, git-vimdiff origin/master.., and just git-vimdiff.

Then, in vim, use Ctrl-N, Ctrl-P to navigate to the next and previous pairs of files. Ctrl-A restarts at the beginning. Ctrl-Q quits.


I run git-vimdiff before sending code out for review. It lets me see the code in the same way how a reviewer would see it (if they were using Reviewboard or Mondrian or gerritt or whatever other side-by-side review tool). Because the right-hand side is editable, I typically add comments, fix spelling errors, and do other cleanup in this last pass.

Note that git-difftool calls vimdiff on every pair of files that change. Hence, navigating requires you popping out of vim.

Technical Minutiae

To avoid complicated installation instructions, git-vimdiff is "statically linked," in that it encompasses two shell scripts and a vim program, but they're all inside of one shell script. The outer shell script calls git diff, which then calls the inner shell script, which copies the changed files. The outer shell script than calls vim, with a supplied vim program to set up diff mode, and navigation.


git-vimdiff is based on a hack by by John Reese ( Philip Zeyliger adapted it for git.