dotar/SpaceVim.d/autoload/open-changed-files.vim

21 lines
746 B
VimL
Raw Normal View History

2020-02-10 10:56:29 +08:00
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 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<CR>