开发者

how to open multiple files in vim after vimgrep

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.


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/


found this plugin pretty helpful in this regard.

http://www.vim.org/scripts/script.php?script_id=1813

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜