[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Multible search and replace?



On Wed, 8 Jan 1997, Rick Macdonald wrote:

> Chad Zimmerman wrote:
> > 
> > Was just wondering if there is a package out that does multiple file
> > search and replaces?  I have to go through my main html directory and make
> > a lot of repetive changes.  Was wondering if there was a package or a perl
> > script laying arround to do this.  Would same me the time of writing one
> > up.
> 
> Are you an Emacs user?
> 
> Emacs has dired-do-query-replace, which is on the Operate drop-down
> mouse
> menu in dired-mode.
> 
> You'd have to execute it once for each change to me made, but at least
> it would
> do all the files each time.

Wow!  For a "modeless" editer, emacs sure has a lot of modes!

In any reasonable vi clone (e.g. nvi, vim, elvis, etc.) you have
basically two modes: insert and command.  If your in insert, hit
the escape key to get into command mode.  Then just type a colon
":" and enter "%s/<text to replace>/text to replace with/g".

This is pretty standard syntax for this sort of thing in unix.
The "%" is a short cut for specifying all lines in the file which
could be done with "1,$" longhand.  The "s" is "swap" or
"switch" or something like that.  The first slash marks the
begginning of the search text.  The second slash separates that
from the replacement text and the last ends the text spec.  The
"g" indicates a global operation for each line specified (in this
case all lines).  The global specification is needed if you want
all incidents of the search text on each line replaced.  So, in
vi just type:

:%s/<whatever>/<whatever else>/g

Very simple.

The text can contain pretty much anything, but some stuff may
need to be esaped with a back slash "\" or input "as is" with a
^V<character>.

Outside of that, I'm sure there must be some handy HTML editors
that can do this as well.

Thanks 

Richard G. Roberto
richr@bear.com
011-81-3-3437-7967 - Tokyo, Japan


--
*******************************************************************************
Bear Stearns is not responsible for any recommendation, solicitation, offer or
agreement or any information about any transaction, customer account or account
activity contained in this communication.
*******************************************************************************


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-REQUEST@lists.debian.org . Trouble? e-mail to Bruce@Pixar.com


Reply to: