[comp.unix.questions] Better vi case-change macro

rich@gtx.com (Rich Holloway) (07/11/89)

I recently posted a macro (created by shaefer@cse.ogc.edu) which will
convert to lower/upper case from the cursor to end-of-line:

	map ~!$ "cd$a:s/\(^V^[pa\)/\L\1/^V^[F:Pl"cd3f/@c^V^M

which had the following caveats:

<shaefer@cse.ogc.edu> wrote:

     It will work UNLESS there is a '/' character in the text to be
     lowercased.  In this case, if there is a space preceding the text to be
     uppercased, you need to start with the cursor on the space.
     
     It won't work if there are regular-expression magic characters in
     the text to be lowercased unless you use :se nomagic.  It can also break
     on long lines if you have wrapmargin set greater than 0.
     

I got a better macro from <...!mcvax!ukc!root44!gwc> (Geoff Clare):
     
     map <whatever> DO^V^[p:s/.*/\L&/^V^M0Dj$pkdd
     
     (here, ^V stands for CTRL-V, ^M for RETURN, and ^[ for ESCAPE).
     
     
     The macro I give above has no restrictions, but is susceptible (as
     is shaefer's) to the common vi bug where, if wrapmargin is set, the 'p'
     command screws up if it reaches the margin.
     
Thanks again to all who answered my question.

-- 
Richard L. Holloway	...!sun!sunburn!gtx!rich      
GTX Corporation,        Phoenix, Arizona