[SLUG] Vim. Search and replace in multiple files

Al Girling al21 at firenet.uk.com
Tue Dec 7 16:25:48 GMT 2004


Hi folks,

Last night I mentioned this to a couple of you and thought it worth
posting to the list in general.

During the thread started by John on the subject of text editors.  The
ability to search and replace within multiple files was raised as a
desirable feature.

Well, I've recently discovered this. If you've opened a bunch of
files, say html pages, with.

$ vim *.html

This will open each file in it's own buffer.  To search and replace
through all the files you need to do this.

:argdo %s/<foo>/<bar>/ge |w

The 'w' seems to work as well as the 'update' option available.  See:

:he argdo

in vim for more details.

I hope this is useful.

Al

-- 
Al Girling
Linux User: #290080            <http://counter.li.org>
Scarborough Linux User Group   <http://www.scarborough.lug.org.uk>





More information about the Scarborough mailing list