我有這些Git的Vim映射。下面的大多數命令都可以工作,但最後一個,gm,根本不起作用。我想打開一個新的Vim(最好用我的git commit消息模板已經加載,按照默認的終端行爲),編輯並保存我的消息,然後提交。在新的Vim窗口中寫入Git commit消息,然後在Vim中提交所有內容
任何想法的另一種方法來解決這個問題?
" 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
更新:
按VonC的建議,我現在用的fugitive.vim。我替換了以前的Vim綁定,並將此插件推薦給使用Vim和Git的任何人。
" fugitive shortcuts
noremap ggs :Gstatus<cr>
noremap ggc :Gcommit<cr>
noremap gga :Gwrite<cr>
noremap ggl :Glog<cr>
noremap ggd :Gdiff<cr>
這並不是我正在尋找的東西(還有一個插件可以保留和學習和使用> _ <),但它可能比我想象的要好。謝謝! – 2010-08-20 16:53:24
我回頭看看你的回答,注意你的示例代碼實際上是用於MinSCM而不是fugitive.vim。不過,感謝fugitive.vim。 :) – 2010-08-20 19:30:29