[comp.unix.questions] Summary to "<tab> to space under vi" -- from original poster

kelvin@gordon.UUCP (Kelvin Lam) (01/28/88)

Hi there!  I'm the person who asked the "<tab> to space under vi" question.
Thank you to all who responsed to my question.

Based on what I get from the mail and reading other's posting:

    There is no direct way to do it in vi, but there are work arounds.

Work arounds:
	1.  Using external filters within 'vi'.  Suppose you have a filter
	    called 'detab' then you can type:
		:%!detab<cr>
	    You can use either (BSD) /usr/ucb/unexpand or (SYS5) 'pr -t -i80'

	2.  Do a global replacement of <tab>.

	3.  Re-map <tab> key to insert n-<space>.
	    Note for method 2 and 3:
		This isn't what I want and it won't get the desired result
		because not all <tab>'s can be replace by 8 spaces.
		Alignment problem, you know.

	4.  Use ^T and ^D instead of <tab> or re-map <tab> to ^T.
	    Note for method 4:
		It only works on leading spaces/tab/indentation.

Kelvin Lam
(...!necntc!gordon!kelvin)

dougs@sequent.UUCP (Doug Schwartz) (01/30/88)

In article <465@gordon.UUCP>, kelvin@gordon.UUCP (Kelvin Lam) writes:
...
> Work arounds:
> 	3.  Re-map <tab> key to insert n-<space>.
> 	    Note for method 2 and 3:
> 		This isn't what I want and it won't get the desired result
> 		because not all <tab>'s can be replace by 8 spaces.
> 		Alignment problem, you know.

I must be missing something here.  I thought you wanted to be able to
insert N spaces when you pressed the Tab key while in {insert/open/append}
mode in vi.  If so, this suggestion will always work (put it in your .exrc
file):

:map!<sp>^V^V<tab>^V^V<sp><sp><sp><sp><sp><sp><sp><sp>

where:

	<sp>	is a space
	<tab>	is a tab
	^V	is control-v

Note that this assumes you are using vi on the .exrc file.
The ^V^V combination is needed, since the first one escapes
the second one which in turn escapes the <tab> or <sp>'s.

If this isn't what you want, tell me where I am amiss.

Now if you use an advanced editor, such as emacs, you could
just:

	(setq tab-width 8)
-- 
Doug Schwartz
Sequent Computer
Beaverton, Oregon
tektronix!ogcvax!sequent!dougs