[comp.unix.wizards] How can you put a `|' in a vi map?

matt@srs.UUCP (Matt Goheen) (01/06/88)

Try as I may, I can't seem to find a way to put a pipe symbol (`|') into
a vi (ex) map.  For example, in vi try:

:map q i|^[

Where '^[' is entered via ^V then the escape key.  Vi says something
like "Unknown command character '^['".  You can try escaping the `|'
with a backslash and get different but equally useless results.  Seems
that I've tried everything (doubling the `|', backslash, etc.).

The problem is that vi thinks the `|' is a command separator no matter what
you do.  I'm trying to write a map that sends a block of text to a series
of pipelined commands (e.g.  'sed "s/^.\* //" | fmt | sed "s/^/\*\* /"'
in a map along with a few other vi commands to fix it up).  I have solved
the problem using a shell script (or mapping three separate shell escapes
into the map command -- ugghh).  It just seems that there MUST be a way
to do this the "right" way...
-- 
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
- UUCP:	{allegra,rutgers,ames}!rochester!srs!matt	Matt Goheen 	-
- "Make you love to hate, and hate to love..."		S.R. Systems	-
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-

wk@hpirs.HP.COM (Wayne Krone) (01/07/88)

> Try as I may, I can't seem to find a way to put a pipe symbol (`|') into
> a vi (ex) map.  For example, in vi try:
> 
> :map q i|^[
> 
> Where '^[' is entered via ^V then the escape key.  Vi says something
> like "Unknown command character '^['".  You can try escaping the `|'
> with a backslash and get different but equally useless results.  Seems
> that I've tried everything (doubling the `|', backslash, etc.).

You have to quote `|' with ^V (ctrl-V).  Try:

:map q i^V|^[

where '^V' is entered via two consecutive ctrl-V's.

Wayne Krone
Hewlett-Packard