home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / editors / 1802 < prev    next >
Encoding:
Text File  |  1992-07-22  |  1.9 KB  |  49 lines

  1. Newsgroups: comp.editors
  2. Path: sparky!uunet!mcsun!sun4nl!wn1.sci.kun.nl!cs.kun.nl!hansm
  3. From: hansm@cs.kun.nl (Hans Mulder)
  4. Subject: Re: Capitalizing first [a-z] letter in sentence in vi
  5. Message-ID: <1992Jul23.010424.4048@sci.kun.nl>
  6. Sender: news@sci.kun.nl (NUnet News Owner)
  7. Organization: University of Nijmegen, The Netherlands
  8. References: <1992Jul20.233831.9582@sci.kun.nl> <1992Jul21.224816.25122@news.acns.nwu.edu> <1992Jul22.141433.26865@sci.kun.nl> <1992Jul22.215752.19032@news.acns.nwu.edu>
  9. Date: Thu, 23 Jul 1992 01:04:24 GMT
  10. Lines: 37
  11.  
  12. In <1992Jul22.215752.19032@news.acns.nwu.edu> navarra@casbah.acns.nwu.edu (John Navarra) writes:
  13. >In article <1992Jul22.141433.26865@sci.kun.nl> I wrote:
  14. >>How about:
  15. >>
  16. >>:g/[.!?])*[ ]*$/+s/[a-z]/\u&
  17.  
  18. >    I am not sure about this one. Can you explain it more? I am getting
  19. >a "Not that many lines in buffer" error when I try it. 
  20.  
  21. OK, how about:
  22.  
  23. :1,$-1g/[.!?])*[ ]*$/+s/[A-Za-z]/\u&
  24.  
  25. It dissects as follows:
  26.  
  27. :        Means that it's an ex command.
  28. 1,$-1        The range of lines it must be applied to: from the first till
  29.         the second last.  Your problem is that the last line ends
  30.         in one of [.!?] and you can't ~ the first char of the last
  31.         line +1, because there are "Not that many lines in buffer".
  32. g        Short for global.  Applies the +s/[a-z]/\u& command to all
  33.         lines matching the pattern /[.!?])*[ ]*$/.
  34. /[.!?])*[ ]*$/     Pattern for lines ending in one of [.!?], possibly some )
  35.         and white space.  Add a tab between the [] if necessary.
  36. +        Short for .+1 i.e. apply the s/// bit to the next line
  37. s/[A-Za-z]/    Replace the first letter...
  38. \u        ...by upper case of version of...
  39. &        ...whatever matched the first argument.
  40.  
  41. In the second argument of the s/// command, the magic sequence \u changes
  42. the next letter to upper case, \U changes everything to upper case until
  43. the next \e or \l or whatever.  The lower case versions are \l and \L.
  44.  
  45. --
  46. Hope this helps,
  47.  
  48. Hans Mulder                hansm@cs.kun.nl
  49.