Andy Stewart 270613bd71 Ignore diff results which aren't actually hunks.
Some people have reported a failure whereby at least one `line` in the
diff results doesn't match the hunk regexp.  I believe, though cannot
say with certainty, that this is due to mismatching newline shenanigans.

However this theory doesn't explain how the failure could occur on a
file without changes, as reported by one person.  Furthermore I think
that the hunk results would have to have double \n characters to cause
this failure, which I don't think would ordinarily occur on Windows or
Unix.

Whatever the reason, this change copes with the situation.
2013-02-27 10:34:07 +01:00
2013-02-20 10:53:23 +01:00

Vim Git Gutter

A Vim plugin which shows a git diff in the 'gutter' (sign column). It shows whether each line has been added, modified, and where lines have been removed.

This is a port of the Git Gutter plugin for Sublime Text 2.

Screenshot

screenshot

In the screenshot above you can see:

  • Line 15 has been modified.
  • Lines 21-24 are new.
  • A line or lines were removed between lines 25 and 26.

Installation

If you don't have a preferred installation method, I recommend installing pathogen.vim, and then simply copy and paste:

cd ~/.vim/bundle
git clone git://github.com/airblade/vim-gitgutter.git

Usage

You don't have to do anything: it just works.

You can turn vim-gitgutter off with :call DisableGitGutter() and on again with :call EnableGitGutter(). If you do this often I suggest adding mappings for these.

FAQ

The colours in the sign column are weird.

The syntax highlighting for your sign column is probably set strangely. Either modify your colorscheme or add this to your ~/.vimrc:

highlight clear SignColumn

Lines removed below a modified line are not shown.

True. This plugin uses Vim's signs which require a sign to be on a line (not between two lines) and only permit one sign per line. Removed lines are signed with an underscore on the line above. If that line has also been modified, the plugin has to choose whether to show the removed-lines sign or the modified-line sign. It prefers the latter.

Alternatives

I'm not aware of any other Vim plugins which (only) show git diffs in the gutter. However these may be of interest:

  • quickfixsigns_vim has a large superset of this functionality.
  • fugitive.vim is a full-on Git wrapper. It doesn't show git diffs in the gutter (ha!) but it does a bazillion other git things.

Intellectual Property

Copyright Andrew Stewart, AirBlade Software Ltd. Released under the MIT licence.

Description
A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks.
Readme 2 MiB
Languages
Vim Script 99.6%
Shell 0.4%