I have these Vim mappings for Git. Most of the commands below work, but the last g mone does not work at all. I want to open a new Vim (preferably with an already loaded git message template, in accordance with the default behavior of the terminal), edit and save my message, and then commit.
Any ideas for another way to approach this?
" git shortcuts
"" show diff in new window
if has("gui_running")
noremap gd :!git diff <BAR> gvim -<CR><CR>
else
noremap gd :!git diff <BAR> vim -<CR><CR>
endif
noremap gs :!git status<CR>
noremap ga :!git add %<CR>
"" edit commit message in new window
if has("gui_running")
noremap gm :!gvim __vim_gitcommitmessage && git commit -F __vim_gitcommitmessage && rm __vim_gitcommitmessage<CR>
else
noremap gm :!vim __vim_gitcommitmessage && git commit -F __vim_gitcommitmessage && rm __vim_gitcommitmessage<CR>
endif
Update:
As suggested by VonC, I am now using fugitive.vim . I replaced previous Vim bindings and recommended this plugin to anyone using Vim and Git.
" fugitive shortcuts
noremap ggs :Gstatus<cr>
noremap ggc :Gcommit<cr>
noremap gga :Gwrite<cr>
noremap ggl :Glog<cr>
noremap ggd :Gdiff<cr>
source
share