Skip to content

Instantly share code, notes, and snippets.

@mattboehm
Created April 4, 2014 16:15
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattboehm/9977950 to your computer and use it in GitHub Desktop.
Save mattboehm/9977950 to your computer and use it in GitHub Desktop.
A mini-plugin to cycle through diffs of unstaged git changes by file (requires fugitive)
nnoremap <silent> <leader>gm :tab split<CR>:Glistmod<CR>
nnoremap <silent> <c-s-j> :call g:DiffNextLoc()<CR>
nnoremap <silent> <c-s-k> :call g:DiffPrevLoc()<CR>
command! Glistmod only | call g:ListModified() | Gdiff
function! g:ListModified()
let old_makeprg=&makeprg
let old_errorformat=&errorformat
let &makeprg = "git ls-files -m"
let &errorformat="%f"
lmake
let &makeprg=old_makeprg
let &errorformat=old_errorformat
endfunction
function! g:DiffNextLoc()
windo set nodiff
only
lnext
Gdiff
endfunction
function! g:DiffPrevLoc()
windo set nodiff
only
lprevious
Gdiff
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment