55224Re: Multiple file find and replace
- Dec 2, 2004
>> I have a friend who uses Textpad and likes the multiple fileI think the OP was looking for how to do it across multiple
>> search and replace. I want to demonstrate this in Vim, but
>> am unsure how to do this.
> :see ":help :s"
files. While Jurgen suggested the "argdo", it's also helpful to
mention "windo" and "bufdo" which are also helpful.
I'll give the caveat that with bufdo and argdo, you leave that
buffer so you'll get an error if the file has been modified.
Thus, you can either ":set hidden" beforehand (and then do a
":wall" to write all the changed files), or you can append "|w"
to the ex command.
So if you have started vim with "vim *.cpp", you can do
(which is my preferred method) or, IIRC, you can do
:argdo %s/foo/bar/ge |w
to make the changes in each file and then write them before
proceeding on to the next file.
So an expanded combination of Jurgen's and Antoine's answers
might yield pointers to
(that last one is for the "e" in the :s command which supresses
error reporting if no changes were made)
Hope this helps,
- << Previous post in topic Next post in topic >>