Hello all. I have several files where I want to make the same
substitution. I can make the substitute command work on a single
file, but I want to make it work on all the files. I have the files
loaded in buffers in vim. Any suggestions?
Sounds like you're looking for bufdo (and perhaps later down the
line, its cousins "argdo" and "windo", and the newly minted "tabdo")
You either need to write the file after each change before
leaving the buffer, or you have to set the 'hidden' setting so
you can proceed to other buffers:
Method 1)
:bufdo %s/foo/bar/g | update
Method 2)
:set hidden
:bufdo %s/foo/bar/g
(review your work here)
:wall
(to write all the changes)
You can learn more at
:help bufdo
:help argdo
:help windo
:help 'hidden'
-tim