Skip to content

Instantly share code, notes, and snippets.

@AndrewVos
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewVos/a9199f37927f5c8bbea8 to your computer and use it in GitHub Desktop.
Save AndrewVos/a9199f37927f5c8bbea8 to your computer and use it in GitHub Desktop.
Use the :G <tab> command in vim to list files that have been modified in a git repository
if !empty(glob(".git"))
function! GitLsFilesModified(A,L,P)
let pattern = a:A
if len(pattern) > 0
return split(system("git ls-files --untracked --modified \| grep " . pattern), "\n")
else
return split(system("git ls-files --untracked --modified"), "\n")
endif
endfunction
command! -complete=customlist,GitLsFilesModified -nargs=1 G :edit <args>
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment