Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!dartvax!coat.com From: andyb@coat.com (Andy Behrens) Newsgroups: comp.unix.questions Subject: Re: tabs in vi Message-ID: <15184@dartvax.Dartmouth.EDU> Date: 23 Aug 89 16:09:44 GMT References: <7901@ardent.UUCP> <36790001@hpindwa.HP.COM> <12187@orstcs.CS.ORST.EDU> Sender: news@dartvax.Dartmouth.EDU Reply-To: andyb@coat.com Organization: Burlington Coat Factory Warehouse Lines: 39 >In article <36790001@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. I assume that you simply want to indent the left margin by 4, 8, 12, etc., spaces. As has been pointed out, ":set tabstop=4" will not work, because it redefines the meaning of tabs instead of using spaces. What you want is :set shiftwidth=4 (:set sw=4), possibly combined with :set autoindent (:set ai) Now, DON'T use the tab key at the left margin; use ^T instead. Each ^T will move 4 positions to the right (inserting combinations of tabs and spaces to get to the correct column). Each ^D at the left margin will move 4 positions to the left. (I suppose you could map TAB into ^T if you wanted to). As an extra bonus, you can now use the "<" and ">" commands to shift a previously-typed block of lines left or right. >> will shift 1 line 6>> will shift 6 lines >} will shift everything to the end of a paragraph >% if the cursor is over a brace or parenthesis, will shift everything until the matching brace or parenthesis. -- Live justly, love gently, walk humbly. Andy Behrens andyb@coat.com uucp: {harvard,rutgers,decvax}!dartvax!coat!andyb bitnet: andyb%coat@dartcms1 Burlington Coat, PO Box 729, Lebanon, N.H. 03766 (603) 448-5000