Path: utzoo!utgpu!water!watmath!clyde!rutgers!iuvax!pur-ee!uiucdcs!bradley!bucc2!brian From: brian@bucc2.UUCP Newsgroups: comp.unix.questions Subject: Re: to space under vi, VI SUM Message-ID: <15100004@bucc2> Date: 24 Jan 88 00:38:00 GMT References: <239@unicom.UUCP> Lines: 63 Nf-ID: #R:unicom.UUCP:239:bucc2:15100004:000:2165 Nf-From: bucc2.UUCP!brian Jan 23 18:38:00 1988 > /* ---------- "Re: to space under vi, VI SUM" ---------- */ > In article <462@gordon.UUCP> kelvin@gordon.UUCP (Kelvin Lam) writes: > >To all the 'vi' expert out there(I hope this is the right group!) > > > >Is there a way to force 'vi' editor to insert appropreiate number of spaces > >when key is hit? That is, instead of inserting the actual , > >n number of spaces are inserted. > > >Kelvin Lam > >(...!necntc!gordon!kelvin) > > > :g/ /s// /g > > globally, search for tabs, substitute 8 spaces globally (on a line). > Vi won't let you map the tab key, or I would suggest making a map! (input > mode macro) for it. Applying the above command may or may not apply to your > situation... > > dan smith > uucp: ..!ucbvax!ucbcad!island!daniel > uucp: ..!ptsfa!unicom!daniel !well!daniels This won't work. Consider the following: ----- col1abcdgarbage garbagenonsense c1asdsasdwug jgiegorgjemore of the same ----- If the 's are actual tabs, the file will look like this: ----- col1 abcd garbage garbage nonsense c1 asds asdwug jgiegorgje more of the same ----- But if the tabs are changed to 8 spaces each, the file becomes: ----- col1 abcd garbage garbage nonsense c1 asds asdwug jgiegorgje more of the same ----- Not quite what is desired. What you really want is something that knows what tabs really are. You could use the following: :1,$! pr -t -e -f But that will give you gratuitous form-feed characters every 66 lines. If your file is less than 66 lines long, no problem. If your file is longer than 66 lines, and you didn't have any form-feed characters in the file to start with, you can use :1,$s/^L//g to delete all the form-feeds (control-L's) in the file. ............................................................................... When the going gets weird, the weird turn pro. { bucs1!brian Brian Michael Wendt {uiucdcs,cepu,ihnp4}!bradley! { brian { bucc2!brian