changing multiple things on one line in vi

Colin Rasor tcaz at tcaz.com
Fri Aug 19 14:55:14 MST 2005


Mike,

 Instead of using a global variable like % replace it with the line
number(s) in question.
:%s/images/pics/g global
:12s/son.gif/daughter.gif/g replaces line 12 all instances
:1,12s/son/daughter/g Replace all instances of son.gif with daughter on
lines 1-12


--Colin.ansel.Rasor

On 8/19/05 2:27 PM, "MCR" <mike1071 at yahoo.com> wrote:

> This is along the line of a couple of posts today, so
> I thought I would finally ask.  When I have a document
> open in vi, sometimes I would like to do a change and
> have it apply to only one line, I know how to do it
> globally, but I can not seem to find out how to do it
> for just the one line.  Example:
> For global: say I have a html document and my image
> directory is named "images".  I decide to change the
> name of the directory to pictures, I know to do this
> for the whole document I do:
> :%s/images/pictures/g
> 
> Now what I can not figure out is if I have the same
> document, and on one line I have a file named son.gif
> four times.  I have the same file name through out the
> document, but just on this one line I need to change
> all four son.gif to daughter.gif.  I do not know how
> to do this.  I have tried:
> :%s/son.gif/daughter.gif <enter>
> 
> but this did not work.  Could someone please offer
> some insight on how to do this.  It would save me a
> lot of typing.  Thank You in advance.
> 
> Mike
> 
> One is led to truth through the interpretation of a myth.
> 
> 
> 
> ____________________________________________________
> Start your day with Yahoo! - make it your home page
> http://www.yahoo.com/r/hs
>  
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change  you mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss




More information about the PLUG-discuss mailing list