Path: utzoo!dciem!client1!kevin From: kevin@client1.DRETOR.UUCP (Socrates) Newsgroups: comp.unix.questions Subject: Re: tabs in vi Message-ID: <2438@client1.DRETOR.UUCP> Date: 23 Aug 89 15:24:33 GMT References: <7901@ardent.UUCP> <36790001@hpindwa.HP.COM> Reply-To: kevin@client1.dciem.dnd.ca (Socrates) Organization: NTT SYSTEMS INC. Lines: 39 In article <36790001@hpindwa.HP.COM> sgordon@hpindwa.HP.COM (Shaun Gordon) writes: >> Is there a way to make it so that when ever I hit the TAB key >> in 'vi' that I get 4 spaces rather than an actual tab? I would >> rather not have to run expand after running vi, as I would only >> want to do that if I actually changed the file. > >While inside vi you can type a colon to get to the command line and then enter: > >set tabstop=4 > This does not appear to be what is desired here. I interpret this as one of the standard vi gripes when indenting by half-tabs. (If you use the above solution then what appears fine from within vi expands to tabstops at 8 columns by cat, more, etc...) There is no easy solution for this, that I have found, however there is a kludge that you can insert into your .exrc. It involves the :map! functions. :map allows you to redefine key meanings, and the ! means that the new definitions apply only within insert mode. The solution I use is to redefine a tab character as four spaces. Only one problem with direct implementation: vi won't recognize the four spaces as existing since it (nicely?) removes whitespace from definitions. To get around this I exit insert mode, then reenter with four spaces entered immediately. There is no noticeable slowdown to perform these extra operations. (I'm using vi on a Sun 3/50 BSD4.2) Here then is the command line to do it: :map! a (ends with 4 spaces) Hope this is what you are after. -- --- Kevin Picott NTT Systems, Inc., Toronto, Ontario "There can be no offense where none is taken" - Japanese Proverb kevin@zorac.dciem.dnd.ca, or on some sites kevin@zorac.ARPA