GitGutter plugin lets you manage your file changes within git-repository with vim by adding signs at the left side to the line numbers.
Also, you can :
- Move between git-hunks (changes chunks)
- Undo your git-hunks
- See all hunks in a vim-split.
To install gitgutter, I'd suggest using Vundle with adding this to your
.vimrc config file:
Then install usually with:
vim +PluginInstall +qall
For more information about installation, check out installation guide provided by the author of the plugin.
To use this plugin all you need to do is first a add file to your git repository and then start making changes in it.
Please be adviced that Vim has an
updatetime flag that I suggest you tweak from 4000ms to (as I checked) around 250ms.
Changing to 250ms is a bit better and less clunky compared to what author suggests with 100ms.
To make that change, add this to your vim-config
Turning gitgutter off
If you don't like how gitgutter works you may uninstall this plugin or if it's only for some of the files you can disable this plugin with vim-command:
Turning gitgutter on
GitGutter toggle on/off
Jumping to next change/chunk
]c for next and
[c for previous.
To customise key-mapping, use this:
nmap ]h <Plug>GitGutterNextHunk nmap [h <Plug>GitGutterPrevHunk
Undoing your hunks
You can undo hanks with
<Leader>hu or re-map key-combination with this:
nmap <Leader>hu <Plug>GitGutterUndoHunk
You can preview hunk with
<Leader>hp or re-map key-combination with this:
nmap <Leader>hv <Plug>GitGutterPreviewHunk
GitGutter Vim-Commands and KeyCombinations:
]h( re-mapped from
[h( re-mapped from
<Leader>hv( re-mapped from
- GitHub - airblade/vim-gitgutter: A Vim plugin which shows a git diff in the gutter (sign column) and stages/undoes hunks.
- vim - What is the <leader> in a .vimrc file? - Stack Overflow
That's it :) Comment, share or don't - up to you.
Any suggestions what I should blog about? Post me a comment in the box below or poke me at Twitter: @anselmos88.
See you in the next episode! Cheers!