VI tabs, termcap solution?

Chris Torek chris at mimsy.UUCP
Thu Feb 4 05:18:50 AEST 1988


In article <5135 at well.UUCP> daniels at well.UUCP (Dan Smith, Social
Mammal...) writes:
>	Here's an area I don't know a lot about, so bear with me... what
>about having a termcap entry invoked when you want to solve this
>"tabs-to-spaces" problem? The termcap entry (ta <str>) would be just like
>the one you usually use, except it would inform vi that your terminal really
>handles tabs as spaces.

I would object very much to an editor that sometimes but not always
quietly changes the TABs I type to spaces (some versions of the
Rand Editor did this, but at least it always did it).  The `ta=<str>'
termcap entry is provided for terminals which can move the cursor
to the next tabstop (a column such that (column mod 8) = 1, if you
start counting from `col 1' as most terminals do), but not via the
ASCII code 1/1 (octal), or 9 decimal, or '\t'.  If the sequence
control-A 8 RETURN moves the cursor to a tabstop, you can put
`ta=^A8\r' into the termcap.

(Actually, the tabstop concept is modified by another termcap
entry which tells how far apart tabs are on the terminal.  Or
if not, it should be.)

Back to the original question (which was `how can I tell vi that
when I type TAB I want the appropriate number of spaces inserted
instead'), the answer is that, purely within vi, you cannot.  The
following will work, but painfully slowly:

	:map! ^V^V^I ^V^V^V^V^I^V^[:.!expand^V^MA

(the ^Vs shown are those you type, not those that are echoed; only
half as many are echoed, and the ^Is are echoed as some number of
spaces).  This also moves you from wherever you were in the line
to the end of the line.  (Use the appropriate `pr' command if you
do not have `expand'.)

The sixty-four dollar question:  Why do you want your tabs changed
to spaces?  Perhaps you can invoke `expand' (or `pr') on files just
before you need them expanded.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list