Vim Fugitive

edit ✏️

:G status
:G commit
:G add %
:G push

Add current file and commit with diff in a split

function! s:GitAdd()
    exe "G add %"
    exe "G diff --staged"
    exe "only"
    exe "G commit"
:command! GitAdd :call s:GitAdd()
nnoremap gic :GitAdd<CR>


C-W o

:on[ly] will make the current buffer the only one on the screen. This is super helpful as many of fugitive commands will open in a split by default.


cycle through the jumplist

This one has nothing to do with fugitive, but is a native vim feature that makes fugitive glorious. Before I realized how to utilize C-i and C-o , I would get completely lost when using fugitive. Digging deep into the log, opening a file from a specific commit, then no way to get back where I was in the log.

C-i jump


show the jumplist

The jumplist is sorted Oldest to newest

:Telescope jumplist

When navigating the jumplist with :Telescope jumplist , it will add a new entry to the jumplist and let you get back to where you were with a C-O .

:Telescope jumplist adds to the jumplist

C-W J / C-W L

:G log

:G log
:G log -p


:Ggrep python **/*md

Unlike :vim[grep] you don't need to specify a file glob.

:Ggrep python

Staging Hunks

In the file you want to stage hunks of run :Gdiff . Then use vim's diff commands ( dp , do , :diffput , :diffget ) to move the hunk between the stage/index. Then write the file to stage.