Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!vsi1!v7fs1!mvp From: mvp@v7fs1.UUCP (Mike Van Pelt) Newsgroups: comp.unix.questions Subject: Re: tabs in vi Message-ID: <489@v7fs1.UUCP> Date: 24 Aug 89 01:26:42 GMT References: <7901@ardent.UUCP> <36790001@hpindwa.HP.COM> <7936@ardent.UUCP> Reply-To: mvp@v7fs1.UUCP (Mike Van Pelt) Organization: Video 7 + G2 = Headland Technology Lines: 28 > 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. The :map! ^V^V ^V^V and set shiftwidth=4 solution that's been mentioned does part of it. What a lot of people seem to be missing is that YOU DON'T WANT ANY TABS AT ALL in the output text -- just spaces, as in the output from expand. To do that, set tabstop=99 in your .exrc file, and autoindent will put in spaces instead of tabs at the beginning of your lines. (Assuming lines don't grow beyond 99 columns, anyway...) Then, when you edit someone else's file with tabs in it, you'll see awful garbage, and have to run the whole file through expand -4. You'll only need to do this once, from then on, the file will be nice and tabless. A quick way to do this is :$ to the end of the file, set a mark with ma, :0 back to the top, then type !'aexpand -4 This runs the text of the file through expand, deletes it all, then replaces it with the output from expand. Note, if you mistype the expand command, it will replace all your text with the error message. The u command will get it back... just make sure caps lock didn't get set somehow, as upper-case U will make it impossible to undo the command. (This one bites me every so often... I hate the F1 caps-lock on the Sun!!!!) -- Mike Van Pelt "Beware the first release, my son, Headland Technology/Video 7 and shun the frumious 1.0" ...ames!vsi1!v7fs1!mvp