Git.vim bindings for fugitive.vim
March 13, 2010
Learn how to set up bindings like git.vim for fugitive.vim, the new kid on the vim git plugin block.
I’ve been a long time user of vim and used to use the rather simple but quite excellent Git.vim for committing to my repo from within vim. I have switched to the godly TPope’s fugitive and knew it was probably better. I haven’t gotten through all the features yet but I definitely started missing my bindings. The bindings Git.vim all use the mapleader key ( key by default). The bindings I used most frequently were:
- Split the buffer and show the output of git status.
- Split the buffer and let you edit the commit message. Saving and writing would commit.
- git add the file in the buffer, staging it for commit.
- Split the buffer and show the output of git log.
- Split the buffer and show the output of git diff for the current file.
To get this functionality in fugitive, add the following to your vimrc
"rebind my favorite commands from Git.vim for Fugitive
nmap <leader>gs :Gstatus<cr>
nmap <leader>gc :Gcommit<cr>
nmap <leader>ga :Gwrite<cr>
nmap <leader>gl :Glog<cr>
nmap <leader>gd :Gdiff<cr>
Thanks to TPope for yet another wonderful plugin. Check out more of his repos on his github account.