Convenient git commit and push

1 Point

Daniel Leong Daniel Leong

10 years ago

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>
git

Pierre Penninckx

Pierre Penninckx 10 years ago

I would also clearly recommend tpope's awesome https://github.com/tpope/vim-fugitive.