[comp.unix.questions] <tab> to space under vi, VI SUM

brian@bucc2.UUCP (01/24/88)

> /* ---------- "Re: <tab> to space under vi, VI SUM" ---------- */
> In article <462@gordon.UUCP> kelvin@gordon.UUCP (Kelvin Lam) writes:
> >To all the 'vi' expert out there(I hope this is the right group!)
> >
> >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...
> 
> dan smith
> uucp: ..!ucbvax!ucbcad!island!daniel       
> uucp: ..!ptsfa!unicom!daniel !well!daniels 

  This won't work. Consider the following:

-----
col1<TAB>abcd<TAB>garbage garbage<TAB><TAB>nonsense
c1<TAB>asds<TAB>asdwug jgiegorgje<TAB>more of the same
-----

  If the <TAB>'s are actual tabs, the file will look like this:
-----
col1	abcd	garbage garbage		nonsense
c1	asds	asdwug jgiegorgje	more of the same
-----

  But if the tabs are changed to 8 spaces each, the file becomes:
-----
col1        abcd        garbage garbage                nonsense
c1        asds        asdwug jgiegorgje        more of the same
-----
 
  Not quite what is desired. What you really want is something that knows
what tabs really are. You could use the following:

  :1,$! pr -t -e -f

  But that will give you gratuitous form-feed characters every 66 lines.
If your file is less than 66 lines long, no problem. If your file is longer
than 66 lines, and you didn't have any form-feed characters in the file
to start with, you can use

  :1,$s/^L//g

  to delete all the form-feeds (control-L's) in the file.

...............................................................................

  When the going gets weird, the weird turn pro.
                                                       { bucs1!brian
  Brian Michael Wendt    {uiucdcs,cepu,ihnp4}!bradley! {       brian
                                                       { bucc2!brian