" Smith) (01/21/88)
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 <tab> key is hit? That is, instead of inserting the actual <tab>, >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... For those who have sent requests for a VI Summary/Macro Tutorial: Thanks! there are a lot of you! I just moved, and looked at the files. I haven't updated them for about a year, and I've learned some things in that time, so I am going to update them. I'll post it late tonight or tomorrow (it's Wed. Morning). I figure there's 5-10 people who might like to see it for every request I've received (~20 so far...), so it makes more sense to post to the net. Thanks for your patience! dan dan smith, island graphics, marin co., ca | "My opinions: you can borrow them, uucp: ..!ucbvax!ucbcad!island!daniel | but don't take them out bowling" uucp: ..!ptsfa!unicom!daniel !well!daniels | (415) 892 TANK (h) 491 1000 (w)
shipley@web5b.berkeley.edu (Peter Shipley) (01/22/88)
In article <239@unicom.UUCP> daniel@unicom.UUCP (Dan "I want to Ski Tam!" Smith) writes: }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 <tab> key is hit? That is, instead of inserting the actual <tab>, }}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... } } For those who have sent requests for a VI Summary/Macro Tutorial: } }dan smith, island graphics, marin co., ca | "My opinions: you can borrow them, }uucp: ..!ucbvax!ucbcad!island!daniel | but don't take them out bowling" }uucp: ..!ptsfa!unicom!daniel !well!daniels | (415) 892 TANK (h) 491 1000 (w) What is wrong with: :%!unexpand Pete Shipley: email: shipley@violet.berkeley.edu Flames: cc-29@cory.berkeley.edu ucbvax!violet!shipley ucbvax!cory!cc-29 Spelling corections: /dev/null Quote: "Anger is an energy"
maart@cs.vu.nl (Maarten Litmaath) (01/23/88)
In article <239@unicom.UUCP> daniel@unicom.UUCP (Dan "I want to Ski Tam!" Smith) writes: \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 <tab> key is hit? That is, instead of inserting the actual <tab>, \>n number of spaces are inserted. \ \ :g/ /s// /g # this is NOT what Kelvin wants: the number of spaces isn't always eight ! \Vi won't let you map the tab key, or I would suggest making a map! (input \mode macro) for it. # this is not true; it's a bit difficult, but it can be done: # use ":map ^V^V^I ^T" e.g. to map tab to "move one shiftwidth to the right" # Remarks: # 1) ^V = control-v (within vi you have to escape the tab, because # it's a separator), ^I = tab, ^T = control-t # 2) you can set the shiftwidth with e.g. ":set sw=4" (default 8) # 3) I can't find a proper solution to the problem myself # 4) I've got an extended vi manual on line (I think it's GOOD); # anybody interested ? Regards. -- Time flies like an arrow, fruit flies |Maarten Litmaath @ Free U Amsterdam: like an orange. (seen elsewhere) |maart@cs.vu.nl, mcvax!botter!ark!maart
jpn@teddy.UUCP (John P. Nelson) (01/23/88)
>>Is there a way to force 'vi' editor to insert appropreiate number of spaces >>when <tab> key is hit? > >Vi won't let you map the tab key, or I would suggest making a map! (input >mode macro) for it. Yes it will. You can use the ^V (control V) character to suppress the normal interpretation of tab as a seperator in a map. From inside vi, you can type the following keystrokes (^V is control v, ^I is tab): :map! ^V^V^I ^V^V ^V^V ^V^V ^V^V This will appear on the screen as the following. Note that two control V characters display as ^V. :map! ^V ^V ^V ^V ^V Anyway, this will map tab to 4 spaces.
domo@riddle.UUCP (Dominic Dunlop) (01/28/88)
Sender: Followup-To: Distribution: In article <6659@agate.BERKELEY.EDU> shipley@web5b.berkeley.edu.UUCP (Peter Shipley) writes: >In article <239@unicom.UUCP> daniel@unicom.UUCP (Dan "I want to Ski Tam!" Smith) writes: >}Is there a way to force 'vi' editor to insert appropreiate number of spaces >}when <tab> key is hit? >What is wrong with: > > :%!unexpand [Hope I've managed to preserve correct attributions in paring that down.] Well, what's wrong with it is that you'd rather vi did the expansion itself automatically. But, failing that, if you haven't got unexpand, then :%!pr -te works as well. But I'd still like to see a more elegant fix. None has yet arrived at this machine. (I did read all received postings before jumping in, honest.) In particular, macros which map tab to a fixed nuber of spaces don't have the desired effect. -- Dominic Dunlop domo@sphinx.co.uk domo@riddle.uucp
beres@cadnetix.UUCP (Tim Beres) (01/28/88)
In article <239@unicom.UUCP> daniel@unicom.UUCP (Dan "I want to Ski Tam!" Smith) writes: >In article <462@gordon.UUCP> kelvin@gordon.UUCP (Kelvin Lam) writes: >> >>Is there a way to force 'vi' editor to insert appropreiate number of spaces >>when <tab> key is hit? That is, instead of inserting the actual <tab>, >>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... Most likely maybe not. The problem being is that if you are at column 4 and hit a <tab>, you end up in column 9 (assuming std. tabs). If you simply replace the above <tab> w/ 8 spaces, the character following the original <tab> will wind up in column 12 - horribly mangling the elegant formatting of the original. Though I don't know how to map a <tab> either, the approach taken in other editors is: 1/ map <tab> to the sequence, a/ determine column position b/ determine the next tab stop c/ add (next tab stop - column) spaces Considering, of course, what to do if there is no next tab stop. If anyone does know how to map tabs, and how to determine the current column under vi, please let me (us) know. Thanks for the quick guides, Dan. Tim -- ----------------------------------------------------------------------- Tim Beres Cadnetix 303/444-8075 x221 5775 Flatirons Pkwy Boulder, CO 80301