home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / editors / 1841 < prev    next >
Encoding:
Internet Message Format  |  1992-07-29  |  1.2 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!convex!news.utdallas.edu!corpgate!bnrgate!nrcnet0!cunews!torn!csd.unb.ca!morgan.ucs.mun.ca!nstn.ns.ca!dragon.acadiau.ca!880139h
  2. From: 880139h@dragon.acadiau.ca (Rob Hutten)
  3. Newsgroups: comp.editors
  4. Subject: Re: Help required in vi editing
  5. Message-ID: <1992Jul29.113354.21849@dragon.acadiau.ca>
  6. Date: 29 Jul 92 11:33:54 GMT
  7. References: <1992Jul28.164526.6394@menudo.uh.edu>
  8. Organization: Acadia University
  9. Lines: 29
  10.  
  11. hsingh@Turing.chem.uh.edu (Harpreet Singh) writes:
  12.  
  13. >    Is there any way (by macro or otherwise) to do such a thing as
  14. >    find a pattern and operate upon it. For Ex. find a comma and
  15. >    then delete till end of line from that point.
  16.  
  17. One way to do this is with a macro:
  18.  
  19. map \d /,^[d$
  20.  
  21. (enter the ^[ by typing control-V ESC)
  22.  
  23. Invoke this macro by typing `\d' (without the quotes).
  24.  
  25. Alternately, you could use a search & replace command such as:
  26.  
  27. %s/,.*$/
  28.  
  29. This would delete all occurances of a comma followed by any text up
  30. until the EOL.  To limit the range of this command, replace the leading `%'
  31. with a range of line numbers, ie:
  32.  
  33. 20s/,.*$/                  - perform command on line 20 only
  34. 20,50s/,.*$/               - perform command on lines 20 through 50 (incl.)
  35.  
  36.  
  37. Hope this gives you some ideas.
  38.  
  39. -Rob
  40.