Reputation: 16802
To to find all modified files in Vim I type
:ls
This will give me a list like so
2 h "index.html" line 98
3 h "Category/Category.Bg_S.js" line 1
4 h "Category/Category.Box0_S.js" line 1
5 + "Category/Category.Box10_S.js" line 1
6 "Category/Category.Box11_S.js" line 1
7 + "Category/Category.Box12_S.js" line 1
But if there are too many buffers this can be tedious. What I was thinking of doing would be something like:
:ls !grep +
to pipe the contents of vim's ls
to shell's grep
function. But it does not work. I therefore have 2 questions:
Upvotes: 2
Views: 598
Reputation: 22266
The easiest way is probably to "redirect" the output to a vim variable, then filter it for modified buffers:
function! GetModifiedBuffers()
redir => bufoutput
buffers " same as ls
redir END
return join(filter(split(bufoutput,'\n'),"v:val =~ '\\%8c+'"),'\n')
endfunction
Then do something like :echo GetModifiedBuffers()
to show the list of modified buffers.
Upvotes: 2