[comp.editors] Tabs and vi

cosell@bbn.com (Bernie Cosell) (02/10/88)

Two questions about tabs from within vi:
  a) for a variety of reasons, I _despise_ true TAB chars.  Is there a
  way to have vi _never_ use them (and just always use the right number
  of spaces).
  b) If I can't have (a), can I at least prevent vi from autoindenting
  by using tabs?  I generally run along with :set ai, and the 
  shiftwidth=4, and what it seems happens is that vi uses
  a TAB character for every <shiftwidth> of indenting (which of course
  looks _great_ once I go back to UNIX where the tab chars become 8
  positions again. :-()

Thanks!.
   __
  /  )                              Bernie Cosell
 /--<  _  __  __   o _              BBN Labs, Cambridge, MA 02238
/___/_(<_/ (_/) )_(_(<_             cosell@bbn.com

hansm@cwi.nl (Hans Mulder) (02/11/88)

In article <20655@bbn.COM> cosell@bbn.com (Bernie Cosell) writes:
>
>Two questions about tabs from within vi:
>  a) for a variety of reasons, I _despise_ true TAB chars.  Is there a
>  way to have vi _never_ use them (and just always use the right number
>  of spaces).

I'm not exactly sure what you want.

If you want to replace all TABs in your file by the correct number of spaces,
  type 1G!Gexpand<CR>.  This runs your entire buffer through expand(1).
If you don't want to see TABs displayed as whitespace, you might want to
  :set list.  This displays (among other things) tabs as ^I.
If you don't want vi to use TABs to position your cursor, remove the pt
  capability from your TERMCAP entry.

>  b) If I can't have (a), can I at least prevent vi from autoindenting
>  by using tabs?  ()

That happens to be easy, just :set tabstops=1024. As you can't have lines
that long this effectively stops vi from ever producing tabs. Of course,
your file should not contain any TABs when you do this.  (And the output
of the :map command is messed up.)

>  I generally run along with :set ai, and the 
>  shiftwidth=4, and what it seems happens is that vi uses
>  a TAB character for every <shiftwidth> of indenting (which of course
>  looks _great_ once I go back to UNIX where the tab chars become 8
>  positions again. :-

You can correct this by running your file through expand -4.  

I am currently running vi version 3.7, 6/7/85 under BSD 4.3, with
:set ai sw=2   and it works correctly, i.e. it generates a TAB for every 
<tabstop> of indenting.

Hope this helps,

>				     Bernie Cosell

				   Hans Mulder

donw@cognos.uucp (Don Walker) (02/22/88)

In article <20655@bbn.COM> cosell@bbn.com (Bernie Cosell) writes:
>
>Two questions about tabs from within vi:
>  a) for a variety of reasons, I _despise_ true TAB chars.  Is there a
>  way to have vi _never_ use them (and just always use the right number
>  of spaces).
>  b) If I can't have (a), can I at least prevent vi from autoindenting
>  by using tabs?  I generally run along with :set ai, and the 
>  shiftwidth=4, and what it seems happens is that vi uses
>  a TAB character for every <shiftwidth> of indenting (which of course
>  looks _great_ once I go back to UNIX where the tab chars become 8
>  positions again. :-()

I work around b) by setting tabstop to some value that I will never be doing
autoindent at (I use set tabstop=80) and setting shiftwidth to the desired
indent value.  This gives you autoindenting without tabs.  It does have two
drawbacks:

1. Any documents that you edit that do contain tabs usually look very
fragmented.  This is usually easy to catch.

2. You can't use the TAB key.

-- 
Don Walker               Cognos Incorporated     S-mail: P.O. Box 9707
Voice: (613) 738-1440                                    3755 Riverside Drive 
  FAX: (613) 738-0002                                    Ottawa, Ontario 
 uucp: decvax!utzoo!dciem!nrcaer!cognos!donw             CANADA  K1G 3Z4

cosell@bbn.com (Bernie Cosell) (02/25/88)

In article <2318@cognos.UUCP> donw@cognos.UUCP (Don Walker) writes:
>
>2. You can't use the TAB key.
>
  Since I posted my original request I have pushed through and fixed
  things for myself.  As for dealing with tabcharacters in the document,
  there are two approaches: one (As Don mentioned) is to set ts=<large>
  the other is to set ts=8 (that is, just leave it alone).  If you do the
  former, then you'll do just as I had originally asked and NEVER get any
  tabs in your document, but if you ever inherit a doc that has them you're
  in for a BIG surprise.  I was going to cope with this just by having
  something bound to :%!expand or some such (I may still!), but since I share
  sources with folk who are not as picky about TAB chars, it'll drive RCS
  *wild* when I check the stuff back in, I really can't do the infinite-ts
  hack.  So i live with ts=8.

  BUT... here's the trick that has made my life MUCH MUCH better -- very
  simple, really:  (Insert enough ^V's to make it work! :-) --
     :map! <tab>  <space><space><space><space>
  It isn't as nice as having REAL soft tab stops, but it works REAL
  good!

  Thanks for all the advice!
   __
  /  )                              Bernie Cosell
 /--<  _  __  __   o _              BBN Labs, Cambridge, MA 02238
/___/_(<_/ (_/) )_(_(<_             cosell@bbn.com