home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / question / 11047 < prev    next >
Encoding:
Text File  |  1992-09-14  |  1.3 KB  |  50 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!nwnexus!Celestial.COM!rayj
  3. From: rayj@Celestial.COM (Ray Jones)
  4. Subject: Re: Replacing words
  5. Organization: Celestial Software, Mercer Island, WA
  6. Distribution: usa
  7. Date: Mon, 14 Sep 1992 16:57:25 GMT
  8. Message-ID: <1992Sep14.165725.26000@Celestial.COM>
  9. References: <6937@tekig7.PEN.TEK.COM>
  10. Lines: 38
  11.  
  12. In <6937@tekig7.PEN.TEK.COM> naren@tekig5.pen.tek.com (naren) writes:
  13.  
  14. >Hi,
  15.  
  16. >I was trying to replace occurrences of XXX with another word YYY.
  17. >I was able to do it two ways.
  18.  
  19. >1.  I went into the vi editor.
  20. >    /XXX
  21. >   [ESC] cw
  22. >   Then I kept hitting n and .
  23.  
  24. >2. I wrote a macro in vi.
  25. >The basic structure was as follows.
  26. >map v: /XXX cw YYY 
  27.  
  28. >3. I tried out a third one.
  29. >This one did not work for some reason.
  30.  
  31. >:$s /XXX/YYY/g
  32.  
  33. >If anyone can come up with better ways, email me
  34.  
  35. Your last command said "on the last line of the file, make the sub.
  36. on all occurances in the line.
  37. What you want is
  38. :%s/XXX/YYY/g
  39. for all occurances on the line, or;
  40. :%s/XXX/YYY/
  41. for the first occurance on the line.
  42. The symbol "%" means for the entire file and means the same as;
  43. :1,$s/XXX/YYY/
  44. or from line 1 to the end of the file.
  45. -- 
  46. Onager Systems             Ray A. Jones
  47. 18710 NE 59th Ct.        UUCP .....uunet!camco!onager!ray
  48. # 2053                   ...ray@onager.Celestial.COM
  49. Redmond, WA 98052               206-885-3568 
  50.