From 10d947d5afd6f8d90e692a9a097d29df3142ca4a Mon Sep 17 00:00:00 2001 From: yan Date: Fri, 27 Apr 2012 00:35:48 -0700 Subject: [PATCH] Added ,ocf for opening changed files (stolen from @garybernhardt) --- README.md | 1 + vim/plugin/settings/open-changed-files.vim | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 vim/plugin/settings/open-changed-files.vim diff --git a/README.md b/README.md index 9637633..feac469 100644 --- a/README.md +++ b/README.md @@ -364,6 +364,7 @@ files contain key mappings as well (TODO: probably will move them out to skwp-ke * `,vr` - (Vim Reload) source current file as a vim file * `,yw` - yank a word from anywhere within the word (so you don't have to go to the beginning of it) * `,ow` - overwrite a word with whatever is in your yank buffer - you can be anywhere on the word. saves having to visually select it + * `,ocf` - open changed files (stolen from @garybernhardt). open all files with git changes in splits * `,w` - strip trailing whitespaces * `sj` - split a line such as a hash {:foo => {:bar => :baz}} into a multiline hash (j = down) * `sk` - unsplit a link (k = up) diff --git a/vim/plugin/settings/open-changed-files.vim b/vim/plugin/settings/open-changed-files.vim new file mode 100644 index 0000000..c5e0599 --- /dev/null +++ b/vim/plugin/settings/open-changed-files.vim @@ -0,0 +1,20 @@ +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" OpenChangedFiles COMMAND +" Open a split for each dirty file in git +" +" Shamelessly stolen from Gary Bernhardt: https://github.com/garybernhardt/dotfiles +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +function! OpenChangedFiles() + only " Close all windows, unless they're modified + let status = system('git status -s | grep "^ \?\(M\|A\)" | cut -d " " -f 3') + let filenames = split(status, "\n") + if len(filenames) > 0 + exec "edit " . filenames[0] + for filename in filenames[1:] + exec "sp " . filename + endfor + end +endfunction +command! OpenChangedFiles :call OpenChangedFiles() + +nnoremap ,ocf :OpenChangedFiles