Search & replace using quickfix list in Vim

前端 未结 6 1794

So far I always used EasyGrep for replacing text in multiple files. Unfortunately it is quite slow when a project gets bigger. One thing that seems to be amazingly fast is G

6条回答
  •  温柔的废话
    2020-12-07 11:04

    nelstrom's answer is quite comprehensive and reflects his brilliant contributions to vimdom. It also goes a bit beyond what is strictly needed here; the quickfix step can be omitted in favor of populating args with the result of a shell command:

    :args `git grep -l findme`
    :argdo %s/findme/replacement/gc
    :argdo update
    

    should be all you need.

    Edit: as Domon notes, :set hidden must be done first if it's not already set!

提交回复
热议问题