Path: utzoo!mnetor!uunet!husc6!cmcl2!beta!hc!ames!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.questions Subject: Re: VI tabs, termcap solution? Message-ID: <10456@mimsy.UUCP> Date: 3 Feb 88 19:18:50 GMT References: <5135@well.UUCP> Distribution: comp Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 41 Keywords: vi tabs macros help In article <5135@well.UUCP> daniels@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 ) 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=' 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@mimsy.umd.edu Path: uunet!mimsy!chris