Relies on vim-fugitive. Maps <leader>gp to "git push." When editing a git commit message, performs :Gwrite to finish the message then :Git pushes to the remote. Otherwise, simply :Git pushes.
function! WriteAndPush()
if expand('%') == "COMMIT_EDITMSG" || expand('%:h') == "COMMIT_EDITMSG"
:Gwrite
:Git push
else
:Git push
endif
endfunction
nnoremap <leader>gp :call WriteAndPush()<CR>
Pierre Penninckx 11 years ago
I would also clearly recommend tpope's awesome https://github.com/tpope/vim-fugitive.