[comp.unix.questions] what does \e do in :s/./\e&/ in vi?

kells@iis.UUCP (Kevin Kells) (05/06/90)

In article <1990May5.193350.3445@chinet.chi.il.us> les@chinet.chi.il.us 
(Leslie Mikesell) writes:
>   :%s/.*/& \L&/
>will do exactly what you ask, 

A little experimentation (didn't use source) proved that there are at
least three such \? "commands" that can be used in this substitution
context. Two I understand: \l (not \L) and \u, which convert upper case
to lower case and vice versa, respectively.  But a third, \e, also
seems to do something, though I can't figure out what.

Is this documented somewhere [besides in the source :-) ] ? Could
someone please tell me what \e does in this context?

Thanks,

Kevin

gpvos@cs.vu.nl (Vos G P) (05/07/90)

kells@iis.UUCP (Kevin Kells) writes:

>A little experimentation (didn't use source) proved that there are at
>least three such \? "commands" that can be used in this substitution
>context. Two I understand: \l (not \L) and \u, which convert upper case
>to lower case and vice versa, respectively.  But a third, \e, also
>seems to do something, though I can't figure out what.

According to the belowmentioned "vi reference":
\l and \u convert the next character (if it's a letter) to uppercase/lowercase.
\L and \U convert all following characters to uppercase/lowercase, until a
\e or \E is found.

>Is this documented somewhere [besides in the source :-) ] ? Could
>someone please tell me what \e does in this context?

I found it in the "vi reference" by Maarten Litmaath. This is published
(ir?)regularly in comp.editors, in two versions: one in Dutch and one in
English.

--
--- Gerben Vos - Aconet: {BBCBBS,LALUNA}!Gerben Vos - UUCP : gpvos@cs.vu.nl   
---- ...Who's afraid of the big bad .signature eatMUNCH CHOMP

dce@smsc.sony.com (David Elliott) (05/07/90)

In article <4381@iis.UUCP> kells@iis.ethz.ch (Kevin Kells) writes:
>A little experimentation (didn't use source) proved that there are at
>least three such \? "commands" that can be used in this substitution
>context. Two I understand: \l (not \L) and \u, which convert upper case
>to lower case and vice versa, respectively.  But a third, \e, also
>seems to do something, though I can't figure out what.

In the 4.3BSD USD section 16 ("Ex Reference Manual"), section 8.5
("Subsitute replacement patterns"), a number of such commands
are documented.

The sequence \& is replaced by the entire matched text.

The sequence \<digit> is replaced by the text matching the <digit>th
expression delimited by \( and \).

The sequence \u and \l convert the next character in the text to
be converted to upper or lower case.

The sequence \U and \L convert the entire next replacement to
upper or lower case.

The sequences \E and \e turn off the case conversion.

An example of using \U and \E together is to convert the text

	This is line 1

using the conversion command :s/^\(.*\)is\(.*\)$/\U\1was\E\2/.  The
result is

	THIS WAS line 1

That is, even the literal "was" is converted to upper-case because
the \U is in force until \E (or \e) is given.
-- 
David Elliott
dce@smsc.sony.com | ...!{uunet,mips}!sonyusa!dce
(408)944-4073
"Nature hates both a vacuum and a vacuum cleaner too" -- The Residents