Block oriented search and replace across multiple files.

Hal Burgiss hal at burgiss.net
Sun Nov 29 21:18:54 UTC 2009


On Sun, Nov 29, 2009 at 12:57:53PM -0500, Hal Burgiss wrote:
> On Sat, Nov 28, 2009 at 10:25:54AM -0800, Ray Parrish wrote:
> > Also, I do not see any indication that Vim can do search, and replace 
> > across multiple files simultaneously, so I'm back to writing my program, 
> > which is coming along nicely.
> 
> See 'bufdo', 'tabdo', 'windo' commands to operate on multiple opened files.
> Depending on where you have the files open (multiple buffers, tabs or
> windows). 
> 
> :tabdo %s/test/x\rx\rx\rx/ge | update

Just to clarify a little, AFAIK you have to open the files you want to operate
on, so something like 'vim *html', would open all html's in the current
directory, and each is in its own 'buffer'. You'll just see one at a time, but
the others are all there and you can move between them, or run commands
against them. So you can use 'bufdo' command to make whatever commands global
against all buffers. tabdo is similar for tabs, so if you open the same files
as 'gvim -p *html' each html is in its own tab now. 

-- 
Hal




More information about the ubuntu-users mailing list