I have these Vim mappings for Git. Most of the commands below work, but the last one, gm, doesn't work at all. I want to open a new Vim (preferrably with my git commit message template already loaded, as per the default terminal behavior), edit and save my message, 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 per VonC's suggestion, I am now using fugitive.vim. I replaced my previous Vim bindings, and would recommend this plugin to anyone who uses 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>