<tab> to space under vi, VI SUMMARY COMING SOON...

Tim Beres beres at cadnetix.UUCP
Thu Jan 28 07:12:42 AEST 1988


In article <239 at unicom.UUCP> daniel at unicom.UUCP (Dan "I want to Ski Tam!" Smith) writes:
>In article <462 at gordon.UUCP> kelvin at gordon.UUCP (Kelvin Lam) writes:
>>
>>Is there a way to force 'vi' editor to insert appropreiate number of spaces
>>when <tab> key is hit?  That is, instead of inserting the actual <tab>,
>>n number of spaces are inserted.
>
>>Kelvin Lam
>>(...!necntc!gordon!kelvin)
>
>
>	:g/	/s//        /g
>
>	globally, search for tabs, substitute 8 spaces globally (on a line).
>Vi won't let you map the tab key, or I would suggest making a map! (input
>mode macro) for it. Applying the above command may or may not apply to your
>situation...

	Most likely maybe not.  The problem being is that if you are at
column 4 and hit a <tab>, you end up in column 9 (assuming std. tabs).
If you simply replace the above <tab> w/ 8 spaces, the character following
the original <tab> will wind up in column 12 - horribly mangling the
elegant formatting of the original.

	Though I don't know how to map a <tab> either, the approach taken
in other editors is:

	1/ map <tab> to the sequence,
		a/  determine column position
		b/  determine the next tab stop
		c/  add (next tab stop - column) spaces

	Considering, of course, what to do if there is no next tab stop.

	If anyone does know how to map tabs, and how to determine the
current column under vi, please let me (us) know.  Thanks for the quick 
guides, Dan.

			Tim

-- 
-----------------------------------------------------------------------
Tim Beres  Cadnetix                  303/444-8075 x221
           5775 Flatirons Pkwy
           Boulder, CO 80301



More information about the Comp.unix.questions mailing list