how to open multiple files in vim after vimgrep

只谈情不闲聊 提交于 2019-12-06 05:00:27

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!