Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!ucsd!mvb.saic.com!unogate!unocal!genisco!arcturus!felix!asylvain@felix.UUCP From: asylvain@felix.UUCP (Alvin "the Chipmunk" Sylvain) Newsgroups: comp.editors Subject: Re: Question on tab stops in vi Keywords: vi tabs Message-ID: <163509@felix.UUCP> Date: 23 May 91 00:38:08 GMT References: <1991May09.190644.13627@Kesa.COM> Sender: daemon@felix.UUCP Reply-To: asylvain@felix.UUCP (Alvin "the Chipmunk" Sylvain) Distribution: comp Organization: Foundation for the Increased Wealth of Chipmunks Send in your pledges now! (Visa/Mastercard accepted) Lines: 66 Written in article <1991May09.190644.13627@Kesa.COM> by jerry@Kesa.COM (Jerry E. Dunmire): > Is there a way to get a 4 space indent in vi without changing tab stops? > > I've tried re-mapping the tab key, but without any luck. This is going to kill you, until you get used to it, but this is at least one solution that will work. What you want is a shift-width of 4. (:set sw=4) Then, when entering your input, instead of hitting "tab", you hit Control-T (^T). No, I'm sorry, you can _not_ map the "tab" into ^T. I've tried, and it won't work. Depending on your terminal, you may be able to map some other key into it, eg., if it's located conveniently, map F3 or some such. But tab? No way. It may be possible, but I doubt it. Rather than entering the "set" command each time, put it in either your EXINIT environment variable, or add it to your $HOME/.exrc file. (I prefer the latter method, as I can add lots of sets and maps and stuff without the en-var getting too long to read.) This will kill you, as it did me, because after implementing this change, you will spend the first month hitting "tab" instead of ^T, getting a tab instead of a 4-space indent, then cursing yourself as you fumble around setting it back to what it should be. If you have auto-indent set (:set ai), you'll also be able to do C and/or Pascal type coding, e.g: if (truth) then Do it Do some more Do everything else else Do some other thing endif With auto-indent set, you won't have to ^T again after the "Do it." It'll just bounce back to the same indent level for "Do some more" and "Do everything else." When it's time to put in the "else," enter ^D, which is a "reverse-tab" of sorts. Entering 0^D brings you back to the left margin. So, your $HOME/.exrc file would look like: set sw=4 set ai *MY* problem is that vi automagically replaces every 8 spaces with a _real_ hardtab (^I), which, at least for posting to the net, I'd like to be able to turn off. So far, if I use indents for anything, I double-check at the end with (:%s/^I/ /g). Does anybody know how to turn _this_ "feature" off? -- Alvin ===== asylvain@felix.UUCP ===== hplabs!felix!asylvain ===== "hplabs!felix!asylvain"@uunet.uu.net (I always try to respond to mail, if possible. If you don't hear back from me, try changing "hplabs" to "ccicpg," "spsd," or "lawnet.") DISCLAIMER: It's all in fun, folks, no flames intended. Any similarity between my opinion and that of my employer is purely coincidental and sufficient reason to change my opinion, although I'll still be right.