Ultimate macvim git commit setup
Took me a while to piece this together. There is a great tip in the macvim github wiki FAQ. Appending the following to your
~/.zshrc, or whatever)
export EDITOR='mvim -f --nomru -c "au VimLeave * !open -a Terminal"'
--nomru switch tells vim not to add the commit message to the Most Recently Used file menu and the
-c switch tells macvim to return the focus to the Terminal app when it quits.
This alone is quite nice, but soon enough you'll start to notice a rather annoying feature, that under normal circumstances is quite useful. If you stop editing a file and re-open the file for editing again Vim will remember the line you were last editing and return you to that line. This gets annoying with commit messages since it will often put your cursor somewhere down in the comments. There is a quick fix for this too though.
You can either add this line to your directly to your
autocmd FileType gitcommit call setpos('.', [0, 1, 1, 0])
Or you can create a file called
~/.vim/ftplugin/gitcommit.vim and add the following to it.
call setpos('.', [0, 1, 1, 0])
Now vim will always place the cursor on the first line of your git commit messages.