Skip to content

Commit

Permalink
add command to open files with uncommitted changes
Browse files Browse the repository at this point in the history
  • Loading branch information
garybernhardt committed Mar 2, 2011
1 parent 3b5fd93 commit 86d12f2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .vimrc
Expand Up @@ -574,3 +574,14 @@ command! -range Md5 :echo system('echo '.shellescape(join(getline(<line1>, <line

imap <c-l> <space>=><space>
function! OpenChangedFiles()
only " Close all windows, unless they're modified
let status = system('git status -s | grep "^ \?\(M\|A\)" | cut -d " " -f 3')

This comment has been minimized.

Copy link
@wickedshimmy

wickedshimmy Mar 2, 2011

You could use git ls-files -m here rather than parsing the output of status if you like, also a bit of future-proofing in case that format changes. (Plus it's faster than forking),

let filenames = split(status, "\n")
exec "edit " . filenames[0]
for filename in filenames[1:]
exec "sp " . filename
endfor
endfunction
command! OpenChangedFiles :call OpenChangedFiles()

0 comments on commit 86d12f2

Please sign in to comment.