Files
vim-gitgutter/README.mkd
2013-03-06 13:51:59 +01:00

130 lines
4.0 KiB
Markdown

## 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][st2gg] plugin for Sublime Text 2.
### Screenshot
![screenshot](https://raw.github.com/airblade/vim-gitgutter/master/screenshot.png)
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][pathogen], and then simply copy and paste:
```
cd ~/.vim/bundle
git clone git://github.com/airblade/vim-gitgutter.git
```
Or for [Vundle](https://github.com/gmarik/vundle) users:
Add `Bundle 'airblade/vim-gitgutter'` to your `~/.vimrc` and then:
* either within Vim: `:BundleInstall`
* or in your shell: `vim +BundleInstall +qall`
### Usage
You don't have to do anything: it just works.
If you want vim-gitgutter off by default, add `let g:gitgutter_enabled = 0` to your `~/.vimrc`.
You can explicitly turn vim-gitgutter off and on:
* turn off with `:GitGutterDisable`
* turn on with `:GitGutterEnable`
* toggle with `:GitGutterToggle`.
And you can turn line highlighting on and off (defaults to off):
* turn on with `:GitGutterLineHighlightsEnable`
* turn off with `:GitGutterLineHighlightsDisable`
* toggle with `:GitGutterLineHighlightsToggle`.
Furthermore you can jump between hunks:
* jump to next hunk: `:GitGutterNextHunk`
* jump to previous hunk: `:GitGutterPrevHunk`.
You may want to add mappings for these if you use them often.
If you want to define your own highlights, you can turn off vim-gitgutter's with `let g:gitgutter_highlights = 0` in your `~/.vimrc`.
### 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
```
> What happens if I also use another plugin which uses signs (e.g. Syntastic)?
Vim only allows one sign per line. Before adding a sign to a line, vim-gitgutter checks whether a sign has already been added by somebody else. If so it doesn't do anything. In other words vim-gitgutter won't overwrite another plugin's signs. It also won't remove another plugin's signs.
### Alternatives
Vim alternatives:
* [git-gutter-vim][ggv]
* [vim-git-inline-diff][vgid]
* [quickfixsigns_vim][qf] (a superset of this functionality)
* [iwilldiffer][iwd]
* [svndiff][svndiff]
* [sign-diff][signdiff]
* [changesPlugin][changes]
Other editors:
* [Git Gutter][st2gg] for Sublime Text 2
* [git-gutter.el][gge] for Emacs
Also, this may be of interest:
* [fugitive.vim][fugitive] is a full-on Git wrapper. It doesn't show git diffs in the gutter (ha!) but it does a bazillion other git things.
### Shameless Plug
If this plugin has helped you, or you'd like to learn more about Vim, why not check out these two screencasts I wrote for PeepCode:
* [Smash Into Vim I][siv1]
* [Smash Into Vim II][siv2]
You can read reviews at PeepCode and also on my [portfolio][].
### Intellectual Property
Copyright Andrew Stewart, AirBlade Software Ltd. Released under the MIT licence.
[st2gg]: https://github.com/jisaacks/GitGutter
[pathogen]: https://github.com/tpope/vim-pathogen
[qf]: https://github.com/tomtom/quickfixsigns_vim
[fugitive]: https://github.com/tpope/vim-fugitive
[siv1]: https://peepcode.com/products/smash-into-vim-i
[siv2]: https://peepcode.com/products/smash-into-vim-ii
[portfolio]: http://airbladesoftware.com/portfolio#vim
[vgid]: https://github.com/luxflux/vim-git-inline-diff
[gge]: https://github.com/syohex/emacs-git-gutter
[iwd]: https://bitbucket.org/sirpengi/iwilldiffer
[svndiff]: http://www.vim.org/scripts/script.php?script_id=1881
[signdiff]: http://www.vim.org/scripts/script.php?script_id=2712
[changes]: http://www.vim.org/scripts/script.php?script_id=3052
[ggv]: https://github.com/akiomik/git-gutter-vim