[comp.editors] tabbing

cheeks@edsr.eds.com (Mark Costlow) (11/14/89)

In article <4468@solo10.cs.vu.nl>, maart@cs.vu.nl (Maarten Litmaath) writes:
[ ... lots of stuff deleted ... ]
> 
> You could always map! tab to ^T:
> 
> 	map! ^V^V^I ^V^T
> 
On every machine I tried this on, the ^I expands to 8 spaces, and I get
"Missing rhs".  (I tried it on Sun-3's and Sun-4s running SunOS 3.4 and 4.0.3,
and HP9000s300s running HP-UX 6.2 and 6.5).  Nothing else I've tried works
either ... does anyone know a way to accomplish this mapping?

cheeks@edsr.eds.com

maart@cs.vu.nl (Maarten Litmaath) (11/14/89)

In article <225@xochitl.UUCP> cheeks@edsr.eds.com writes:
\In article <4468@solo10.cs.vu.nl>, maart@cs.vu.nl (Maarten Litmaath) writes:
\[ ... lots of stuff deleted ... ]
\> 
\> You could always map! tab to ^T:
\> 
\> 	map! ^V^V^I ^V^T
\> 
\On every machine I tried this on, the ^I expands to 8 spaces, and I get
\"Missing rhs".  (I tried it on Sun-3's and Sun-4s running SunOS 3.4 and 4.0.3,

It must be something in your other maps, or still something else, because
here, *using SunOS 4.0.3*, it works!
(Of course the tab would expand to 8 spaces, as long as the shiftwidth is 8.)
-- 
"Richard Sexton is actually an AI program (or Construct, if you will) running
on some AT&T (R) 3B" (Richard Brosseau) | maart@cs.vu.nl, mcsun!botter!maart

mercer@ncrcce.StPaul.NCR.COM (Dan Mercer) (11/15/89)

In article <225@xochitl.UUCP> cheeks@edsr.eds.com writes:
:In article <4468@solo10.cs.vu.nl>, maart@cs.vu.nl (Maarten Litmaath) writes:
:[ ... lots of stuff deleted ... ]
:> 
:> You could always map! tab to ^T:
:> 
:> 	map! ^V^V^I ^V^T
:> 
:On every machine I tried this on, the ^I expands to 8 spaces, and I get
:"Missing rhs".  (I tried it on Sun-3's and Sun-4s running SunOS 3.4 and 4.0.3,
:and HP9000s300s running HP-UX 6.2 and 6.5).  Nothing else I've tried works
:either ... does anyone know a way to accomplish this mapping?
:
:cheeks@edsr.eds.com

I was not able to do this from the command line.  However,  it was
quite easy to do in a source file or .exrc file

map ^V^V^I<space>^T^V^M

-- 

Dan Mercer
Reply-To: mercer@ncrcce.StPaul.NCR.COM (Dan Mercer)

lee@sq.sq.com (Liam R. E. Quin) (11/18/89)

In article <4530@ski.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes:
>In article <225@xochitl.UUCP> cheeks@edsr.eds.com writes:
>\In article <4468@solo10.cs.vu.nl>, maart@cs.vu.nl (Maarten Litmaath) writes:
>\> You could always map! tab to ^T:
>\> 
>\> 	map! ^V^V^I ^V^T
>\> 
>\On every machine I tried this on [...] I get "Missing rhs".
>
Well, if you are typing this from vi, instead of putting it in your .exrc or
EXINIT, you need
	:map! ^V^V^V^I ^V^V^V^T
which works just fine.
In you .exrc, you might need instead
	map! ^V^I ^V^T

where ^V means control-V typed as one character, not ^ followed by V.

In ex, a ^V means that the next character is to be taken literally.  It is
like ^V in the BSD "new crt" tty driver, not like System V "\".
Now, ex normally skips tabs, so you need to tell it that the tab is
special.  Thus, you need to precede it with a single ^V.
So, in ex,	
    map! ^V^I LHS
will make a tab (assuming your tab key sends control-I) send LHS.
In vi, however, ^V is also interpreted.  When you do a : command from vi,
the string you type is read by vi (which strips off ^V, of course), and
passed to ex.  Hence, you need to type ^V^V to make vi send a ^V.
So now we get
    map! ^V^V^V^I LHS
Why three?  The third is needed to protect the coontrol-I (TAB) from vi.

The same reasoning applies to the Left Hand Side (LHS), ^V^V^V^T.


In general, you will always type an ODD number of ^V characters --
almost always one or three.

Note that your .exrc is read by ex, not vi (hence the name).
In other words, when you start vi, it reads your .exrc in "ex" mode,
which is why you only need one ^V there.

Finally, if your TAB key does not send control-I, you will need to
replace ^I with whatever it *does* send.  For example, if it sends
escape control-I h
your map! line would look like (in ex)
	:map! ^V^[^V^I ^V^T
and in vi
	:map! ^V^V^V^[^V^V^V^I ^V^V^V^T

Hope this clarifies things.

Lee
-- 
Liam R. Quin, Unixsys (UK) Ltd [note: not an employee of "sq" - a visitor!]
lee@sq.com (Whilst visiting Canada from England)
lee@anduk.co.uk (Upon my return to England at Christmas)