home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.editors
- Path: sparky!uunet!mcsun!sun4nl!wn1.sci.kun.nl!cs.kun.nl!hansm
- From: hansm@cs.kun.nl (Hans Mulder)
- Subject: Re: Capitalizing first [a-z] letter in sentence in vi
- Message-ID: <1992Jul23.010424.4048@sci.kun.nl>
- Sender: news@sci.kun.nl (NUnet News Owner)
- Organization: University of Nijmegen, The Netherlands
- 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>
- Date: Thu, 23 Jul 1992 01:04:24 GMT
- Lines: 37
-
- In <1992Jul22.215752.19032@news.acns.nwu.edu> navarra@casbah.acns.nwu.edu (John Navarra) writes:
- >In article <1992Jul22.141433.26865@sci.kun.nl> I wrote:
- >>How about:
- >>
- >>:g/[.!?])*[ ]*$/+s/[a-z]/\u&
-
- > I am not sure about this one. Can you explain it more? I am getting
- >a "Not that many lines in buffer" error when I try it.
-
- OK, how about:
-
- :1,$-1g/[.!?])*[ ]*$/+s/[A-Za-z]/\u&
-
- It dissects as follows:
-
- : Means that it's an ex command.
- 1,$-1 The range of lines it must be applied to: from the first till
- the second last. Your problem is that the last line ends
- in one of [.!?] and you can't ~ the first char of the last
- line +1, because there are "Not that many lines in buffer".
- g Short for global. Applies the +s/[a-z]/\u& command to all
- lines matching the pattern /[.!?])*[ ]*$/.
- /[.!?])*[ ]*$/ Pattern for lines ending in one of [.!?], possibly some )
- and white space. Add a tab between the [] if necessary.
- + Short for .+1 i.e. apply the s/// bit to the next line
- s/[A-Za-z]/ Replace the first letter...
- \u ...by upper case of version of...
- & ...whatever matched the first argument.
-
- In the second argument of the s/// command, the magic sequence \u changes
- the next letter to upper case, \U changes everything to upper case until
- the next \e or \l or whatever. The lower case versions are \l and \L.
-
- --
- Hope this helps,
-
- Hans Mulder hansm@cs.kun.nl
-