Better vi case-change macro
Rich Holloway
rich at gtx.com
Tue Jul 11 05:44:35 AEST 1989
I recently posted a macro (created by shaefer at 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 at 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
More information about the Comp.unix.questions
mailing list