5

I recently switched to vim, and learnt that you can execute searching using AG.

I always do

:Ag foo

And, in the quicklist window

:cdo s/foo/bar/g |update

However,it opens all the files in buffers.How can I not let Vim open buffers,but let vim replace words?

shigg
  • 792
  • 1
  • 8
  • 24

1 Answers1

10

use :cfdo and close all the buffers you've opened and modified:

:cfdo :bd

So the workflow is as follows:

:Ag foo
:cdo %s/bar/baz/g | update 
:cfdo :bd

While :cdo iterates over each entry in the quickfix list, :cfdo moves over each file referenced in the list.

gregory
  • 10,969
  • 2
  • 30
  • 42