home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!nwnexus!Celestial.COM!rayj
- From: rayj@Celestial.COM (Ray Jones)
- Subject: Re: Replacing words
- Organization: Celestial Software, Mercer Island, WA
- Distribution: usa
- Date: Mon, 14 Sep 1992 16:57:25 GMT
- Message-ID: <1992Sep14.165725.26000@Celestial.COM>
- References: <6937@tekig7.PEN.TEK.COM>
- Lines: 38
-
- In <6937@tekig7.PEN.TEK.COM> naren@tekig5.pen.tek.com (naren) writes:
-
- >Hi,
-
- >I was trying to replace occurrences of XXX with another word YYY.
- >I was able to do it two ways.
-
- >1. I went into the vi editor.
- > /XXX
- > [ESC] cw
- > Then I kept hitting n and .
-
- >2. I wrote a macro in vi.
- >The basic structure was as follows.
- >map v: /XXX cw YYY
-
- >3. I tried out a third one.
- >This one did not work for some reason.
-
- >:$s /XXX/YYY/g
-
- >If anyone can come up with better ways, email me
-
- Your last command said "on the last line of the file, make the sub.
- on all occurances in the line.
- What you want is
- :%s/XXX/YYY/g
- for all occurances on the line, or;
- :%s/XXX/YYY/
- for the first occurance on the line.
- The symbol "%" means for the entire file and means the same as;
- :1,$s/XXX/YYY/
- or from line 1 to the end of the file.
- --
- Onager Systems Ray A. Jones
- 18710 NE 59th Ct. UUCP .....uunet!camco!onager!ray
- # 2053 ...ray@onager.Celestial.COM
- Redmond, WA 98052 206-885-3568
-