Reputation: 30384
I'm using gvim. Using vimgrep
on current directory to find text across *.sql
files. As it searches files, it just shows me file name at a time and in the end opens one file up.
Is it possible to open all files as tabs? Basically I want to open all files because I want to replace the 'vimgrepped' pattern with a some other text.
Upvotes: 2
Views: 1210
Reputation: 28944
To automate actions on the QuickFix list locations, I have written a command
similar to :bufdo
or :windo
that executes a command for each item.
command! -nargs=+ Qfixdo call QuickFixDo(<q-args>)
function! QuickFixDo(cmd)
let bufnam = {}
for q in getqflist()
let bufnam[q.bufnr] = bufname(q.bufnr)
endfor
for n in keys(bufnam)
exe 'buffer' n
exe a:cmd
update
endfor
endfunction
Using the function one can open all files mentioned in the QuickFix list by the following command.
:Qfixdo tab sp
In addition, it is possible to repeat the substitution itself the same way.
:Qfixdo %s/pattern/string/
Upvotes: 1
Reputation: 30384
found this plugin pretty helpful in this regard.
http://www.vim.org/scripts/script.php?script_id=1813
Upvotes: 1