From spencer@lit.Princeton.EDU (S. Spencer Sun) Subject: Re: A program to /* comment out */ automaticaly Date: 22 Oct 92 03:50:26 GMT Reply-To: spencer@phoenix.princeton.edu (S. Spencer Sun) This doesn't strike me as being a shell question so I've crossposted to c.u.misc and directed followups there. In article , guy@mais.hydro.qc.ca (Guy Harel) writes: >I was always bothered by the tedious task of placing /*`s and */`s >around lines of code, and always wondered why on earth haven`t such a >facility ever been provided (maybe EMACS does this , I`m not sure). > >[other comments removed] > >#!/bin/csh > >exec awk '{ print "/* " $0 " */" }' Why start another process? Since you say you're using vi: 1. Move to start of block you want to comment out 2. Type ma (set mark a) 3. Move to end of block you want to comment out 4. issue :'a,.s/^\(.*\)$/\/\* \1 \*\// Voila. If you just want to do one line, just do step 4 and leave out the 'a,. part. (Yes, I've tried this out just to be sure, but I may have made a typo. If it doesn't work, someone will no doubt correct the typo) Don't want to memorize this, or don't want to learn what's really going on here so you can generalize to other useful things? Type it once and put it in your .exrc. map This line in $HOME/.exrc will replace with whatever key (if you want, say, ^A, you have to hit ^V^A to insert the actual control character) and with the nasty-looking stuff above. All of this assumes you WANT to comment out a large block this way. Why not just do this? Guess it's a matter of preference. /* this is some code that I want commented out */ much easier to un-comment later, too. ----- sss/PU'94 Dept of CS (spencer@phoenix.princeton.edu)/JvNCnet (spencer@jvnc.net) "I once believed in causes too / I had my pointless point of view / And life went on no matter who was wrong or right..." [Billy Joel, "Angry Young Man"] From bill@bilver.uucp (Bill Vermillion) Subject: Re: A program to /* comment out */ automaticaly Date: Thu, 22 Oct 1992 21:11:16 GMT In article <1992Oct22.035026.25734@Princeton.EDU> spencer@phoenix.princeton.edu (S. Spencer Sun) writes: >This doesn't strike me as being a shell question so I've crossposted to >c.u.misc and directed followups there. >In article , guy@mais.hydro.qc.ca (Guy Harel) writes: >>I was always bothered by the tedious task of placing /*`s and */`s >>around lines of code, and always wondered why on earth haven`t such a >>facility ever been provided (maybe EMACS does this , I`m not sure). >>[other comments removed] >>#!/bin/csh D>> >>exec awk '{ print "/* " $0 " */" }' >Why start another process? >Since you say you're using vi: >1. Move to start of block you want to comment out >2. Type ma (set mark a) >3. Move to end of block you want to comment out >4. issue > :'a,.s/^\(.*\)$/\/\* \1 \*\// >Don't want to memorize this, or don't want to learn what's really going on >here so you can generalize to other useful things? Type it once and put >it in your .exrc. >map >This line in $HOME/.exrc will replace with whatever key (if >you want, say, ^A, you have to hit ^V^A to insert the actual control >character) and with the nasty-looking stuff above. Gee - this one looks easier to type. ;-) map ^X ^i/* ^[A */^[^ And to comment out a line just to /* to anywhere in that line and type control x */ just like that! -- Bill Vermillion - bill@bilver.oau.org bill.vermillion@oau.org - bill@bilver.uucp - ..!{peora|ge-dab|tous|tarpit}!bilver!bill From martelli@cadlab.sublink.org (Alex Martelli) Subject: Re: VI??? GROSS! Date: 17 Nov 92 08:21:34 GMT wolff@inf.fu-berlin.de (Thomas Wolff) writes: :Most repliers to my posting seem to be that well accustomed to the fact :that vi is a line editor that they didn't see my point when I wrote :"arbitrary (!) block of text" (well, maybe "block" was misleading). This :is not a block of lines (which is the unit of most vi operations) and :since I referred to "elementary text editing tasks" I didn't mean columns :either. Suppose I have the lines : word1 word2 word1 : word3 word4 word3 :and I need the text from "word2 " up to "word4" (assume it's a sentence) :to be copied or moved elsewhere.If an editor cannot do this with a :simple command sequence (and without the search trick burdening me with :the task of counting the occurences of the word following my sentence :within my sentence, if it can be done that way at all), I just do not :call it a text editor. You don't seem to be READING the responses to your post! 1. Place the cursor on the leading "w" of "word2". (by any means whatsoever). 2. Press: ma You have thus placed the marker named a on that point. 3. Place the cursor on the final "4" of "word4". (again, by any means whatsoever). 4. Press: mz You have thus placed the marker named z on that point. (note that you have 26 marks at your disposal, named a to z). 5. Press: `a You will move to the EXACT point of mark a, the leading w of "word2". Note that this is a BACKquote, also known as GRAVE ACCENT, *NOT* an apostrophe. The apostrophe would use the mark for line-oriented operation; the backquote uses it for character-stream operation. If you don't like this key assignment place a "map ' `" in your .exrc, and the apostrophe will start working in charstream too. 6. To COPY, press: "ay`z You have thus yanked the EXACT block of text you're interested in, into named-buffer a. Note that a BACKQUOTE is needed here, too, before the z, unless you've mapped things to work differently. (You have 26 named buffers at your disposal, named a to z). (If you *already* had text inside named-buffer a, and you wanted to APPEND these words to that, you could do this by pressing: "Ay`z - the uppercasing of the buffer name is the trick. By using the buffername in lowercase, the previous contents of the buffer are, instead, replaced). 6bis. Or, to MOVE, press: "ad`z You have thus *deleted* the exact block of text into the named buffer. 7. Now place the cursor wherever you wanted to place the text. (yet again, by any means whatsoever). 8. Press: "ap You have put named-buffer a's contents right after the cursorpoint. Or, Press: "aP to put the same contents right BEFORE the cursorpoint. Note that in either case the contents go within the textstream at the cursorpoint, as they have been yanked or deleted as textstream, not as whole lines. I don't claim this process is perfect. No immediate visual feedback is available of where marks are, or what you have yanked. The use of both lower and upper case for commands, which are not echoed, is at first confusing, although the mnemonic relationships make it rather commodious to use after a while (p-ut after, P-ut before; "a to overwrite buffer a, "A to append to it; and so on). I *DO* claim that you have flamed the vi editor, and by implication us, its users, WITHOUT having taken the trouble to learn it AT ALL! Such characterstream operation, and the backquote movement-command in particular, are not some sort of "exoterica", but, rather quite fundamental usage modes of this program! -- Email: martelli@cadlab.sublink.org Phone: ++39 (51) 6130360 CAD.LAB s.p.a., v. Ronzani 7/29, Casalecchio, Italia Fax: ++39 (51) 6130294 From jxh@math.ksu.edu (James C. Hu) Subject: Re: Centering lines in vi Date: 28 Jan 1993 16:43:08 -0600 pietro@nova.bellcore.com (Pietro Manzoni) writes: >Hi, >is there anybody who knows whether there is a :map command to center a >single line in VI? There is probably already a package that does this, but I'd put this in as an example on how to build useful simple filters for vi. At the end of this post is a simple program that centers text. Compile it and install it in ~/bin/center, or whatever. Then, make the following map: :map == !!center^M (the ^M represents the result of hitting CTRL-V followed by CTRL-M) Presto, you have a pseudo center "operator". Now you can do a == to center a single line, or a 5== to center the next 5 lines. Enjoy. /* File: center.c * Creator: James C. Hu (sirius@matt.ksu.ksu.edu) * * Description: * Centers lines of input. * * Caveats are that lines cannot be longer than the specified * centering line length, if they are, then they may be truncated, * and that the default centering line length is 72. * * Copyright: * This program is placed into the public doman. * * Date Started: Thu Jan 28 15:33:44 CST 1993 * * Change Log: */ #include #include #include static int length = 72; static char *buf; static char format[10]; /* should be enough */ int main(int argc, char *argv[]) { int i,n,buflen; char *p; switch(argc) { case 2: length = atoi(argv[1]); if (length == 0) length = 72; case 1: break; default: fprintf(stderr, "usage: center [width]"); exit(1); } buf = malloc((length + 2) * sizeof(char)); while (fgets(buf, length+2, stdin) != NULL) { if ((p = strrchr(buf, '\n')) != NULL) *p = '\0'; while (isspace(*buf)) buf++; buflen = strlen(buf); sprintf(format, "%%%ds\n", length/2 + (buflen+1)/2); printf(format, buf); } return 0; } -- James C. Hu (jxh@math.ksu.edu), 1804 Denholm Dr., Manhattan, KS 66502 I speak for me, the whole me, and nothing but for me. So help me me. From jxh@math.ksu.edu (James C. Hu) Subject: Re: Centering lines in vi Date: 29 Jan 1993 01:40:31 -0600 jxh@math.ksu.edu (Me) wrotes: >There is probably already a package that does this, but I'd put this in >as an example on how to build useful simple filters for vi. At the end >of this post is a simple program that centers text. Compile it and >install it in ~/bin/center, or whatever. >Then, make the following map: >:map == !!center^M >(the ^M represents the result of hitting CTRL-V followed by CTRL-M) >Presto, you have a pseudo center "operator". Now you can do a == to >center a single line, or a 5== to center the next 5 lines. Whups, major bug in my center program. Here's a fixed version. /* File: center.c * Creator: James C. Hu (sirius@matt.ksu.ksu.edu) * * Description: * Centers lines of input. * * Caveats are that lines cannot be longer than the specified * centering line length, if they are, then they may be truncated, * and that the default centering line length is 72. * * Copyright: * This program is placed into the public doman. * * Date Started: Thu Jan 28 15:33:44 CST 1993 * * Change Log: * Date: Fri Jan 29 01:36:57 CST 1993 * Fixed a bug in the inner loop: buf would creep up to the end of * its allocated space. * */ #include #include #include static int length = 72; static char *buf; int main(int argc, char *argv[]) { char format[10]; /* should be enough */ int buflen; char *p; switch(argc) { case 2: length = atoi(argv[1]); if (length == 0) length = 72; case 1: break; default: fprintf(stderr, "usage: center [width]"); exit(1); } buf = malloc((length + 2) * sizeof(char)); while (fgets(buf, length+2, stdin) != NULL) { if ((p = strrchr(buf, '\n')) != NULL) *p = '\0'; p = buf; while (isspace(*p)) p++; buflen = strlen(p); sprintf(format, "%%%ds\n", (length + buflen)/2); printf(format, p); } return 0; } -- James C. Hu (jxh@math.ksu.edu), 1804 Denholm Dr., Manhattan, KS 66502 I speak for me, the whole me, and nothing but for me. So help me me. From lind@eng.umd.edu (Charles A. Lind) Subject: vi? CAPS --> small Date: 3 Feb 1993 13:29:46 GMT Hi, Within vi is there a way to change all capital letters to small letters, or vice versa. Is this possible? Thanks Charles lind@eng.umd.edu -- ------------------------------------------------------ Charles Lind -- lind@eng.umd.edu Department of Aerospace Engineering University of MD, College Park, MD 20742 From edwin@integow.integrity.nl (Edwin Koedam) Subject: Re: vi? CAPS --> small Date: 4 Feb 93 08:10:50 GMT Charles writes: : : Hi, : Within vi is there a way to change all capital letters to small : letters, or vice versa. Is this possible? : : Thanks : : Charles : lind@eng.umd.edu To change capital letters into small ones, just use: :%s/./\l&/g To change small letters into capital ones, just use: :%s/./\u&/g \l& means: Change the found character to lowercase. \u& means: Change the found character to uppercase. Hope this helps Edwin From hansm@cs.kun.nl (Hans Mulder) Subject: Re: vi? CAPS --> small Date: Thu, 4 Feb 1993 12:00:02 GMT In <1kohcaINNk41@mojo.eng.umd.edu> lind@eng.umd.edu (Charles A. Lind) writes: > Within vi is there a way to change all capital letters to small >letters, or vice versa. Is this possible? To downcase everything: :%s/.*/\L& To upcase everything: :%s/.*/\U& HansM From jmd@bealfeirste (John Downey) Subject: Re: vi: Including blank line in search string? Date: 4 Feb 93 13:10:28 GMT Reply-To: jmd@muppet.bt.co.uk J R Evans (ngse18@castle.ed.ac.uk) wrote: +--------- | | I work on a range of different machines, mostly using vi on Unix systems, | for the usual reason that it's always available. One trick which has | always escaped me is how to search for a string which extends over a | line end (indeed, this seems to be a problem for all the standard | Unix search utilities). As an example of the requirement, I was | looking through my mail folders for the "start of message" sequence -- | "From ". Is there a solution within (generic) vi? | | Russ | +--------- You can't search for a pattern that crosses a line boundary; but you can specify a match at the beginning of a line, by typing: /^From / (The final '/' isn't actually needed, but I've put it in to show the preceding space.) This will solve the particular problem you mention because most mail transfer agents will change a line starting with "From" in the body of a message to ">From" anyway. Regards, John Downey Work: Paper mail: MLB 1/21 BT Research Labs Martlesham Heath, Ipswich, Suffolk, England Mail: jmd@cyclone.bt.co.uk Telephone: (UK) 0473 649626 (international) +44 473 649626 Home: Paper mail: 55a Sutherland Sq., London SE17, England Telephone: (UK) 071 708 1299 (international) +44 71 708 1299 From jmd@bealfeirste (John Downey) Subject: Re: replace with CR? Date: 4 Feb 93 14:54:14 GMT Reply-To: jmd@muppet.bt.co.uk Charles A. Lind (lind@eng.umd.edu) wrote: +--------- | | I have a line of words in the form: | | joe, pete, ron, mary, rich, nick, ted | | and I would like to change all the ',' to so that | I get | | joe | pete | ron | mary | rich | nick | ted | | I guess something of the form | | :1,$ s/, //g | | is what I am looking for. | | In general I guess I am looking for the representation for , | , etc. I looked in cs.uwp.edu but I could not find this. | | Thanks | | Charles | +--------- In vi, type :s/, */^M/g You have to type control-V followed by control-M to get the ^M. An ASCII newline is actually control-J, not control-M, but vi won't let you insert control-J into a command line. It's a bit illogical. In xvi, type !!sed 's/, */\^J/g' You have to type control-V followed by control-J to get the ^J. Regards, John Downey Work: Paper mail: MLB 1/21 BT Research Labs Martlesham Heath, Ipswich, Suffolk, England Mail: jmd@cyclone.bt.co.uk Telephone: (UK) 0473 649626 (international) +44 473 649626 Home: Paper mail: 55a Sutherland Sq., London SE17, England Telephone: (UK) 071 708 1299 (international) +44 71 708 1299 From davisonj@en.ecn.purdue.edu (John M Davison) Subject: vi questions. HELP! Date: Mon, 1 Feb 93 14:41:02 GMT Help! The following vi questions are plaguing me: 1. Is there a way to do the equivalent of :s///g without it failing (i.e. stopping the macro in progress) if no tabs are found? 2. Is there a way to encode the "|" character in a "map" command? Presently, when I attempt to include the "|" character in a "map" command, vi ignores the "|" and everything else that follows it in the line, as if it were a trailing comment delimiter. 3. Is there any standard, terminal-independent way of mapping sequences initiated by function keys, i.e. " k"? (My current way of mapping these sequences is on a terminal-by-terminal basis. No mnemonics, just raw sequences.) I want to map function keys, application keypad keys, and arrow keys in vi, but I don't know of any non-terminal-specific mnemonics that I can use for the mappings. Are there? I don't see anything in the ex/vi references I've looked at. The following .exrc (see end of this article) works, but only for a vt100-series terminal. How can I make this work more universally (i.e. with WYSEs and other terminals)? Also, with an LK-201 keyboard (DEC vt2xx and up), how do I specify the PF keys versus the F keys? Is there any standard way of doing it, or do people just tweak their termcap/terminfo entries as they go along? 4. What sequences of ASCII and non-ASCII (8-bit) characters can and cannot be mapped by the "map" function? It seems that any sequence that contains either a space or a LF character, for example, cannot be mapped. 5. Is there any facility in vi that allows one to map a key, in append mode, to something which, unlike a macro, can invoke some user-defined algorithm complete with conditional branches, loops, etc.? I am looking for something that would do the vi equivalent of mapping a key to a TPU function (for those familiar with Digital Equipment Corporation's TPU). 6. Is there a way to make the "autoindent" feature put in spaces instead of tabs? Coherent answers to any and all of these questions are appreciated! I'll post a summary if someone wants me to. In the meantime, here is my .exrc file (if anyone is interested) and, after that, a file containing function key sequences for various terminals and terminal emulators: ------------------------------------------------------------------------------- begin 0 .exrc.Z M'YV0(@(*'$BPH,&#"!,J7"A"@0@0$"-&3`(B3!L09]ZD<7,&!)TW(.#4H0-B MSILV94"(>>.F3`LT9<*0*4,&Q)B3*-W0F0,"IIR484C2@>GQ#1P0;\QX)`JB MX4,79?#(&0/"3!HV*>OHO`J"XIDR),.H!$NGC)RJ9/'D"-+GAS1*>7+F#-KAFCY M,16B5N7,$8IF8T>*<]S685/S)\HV8LR"2,-S:-"X36VBH1MF3-FSM$'@I5G9 M8NG("7/5M$V<972R4#ER-LDQ@$^0C"U\#O&-%9O^A?.P[]_`T^=L')-R M:$K.ALX`F'+LFDN,VDWD\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X02&N4,9TB"'+REY!7'.Y&/M@H(ZS^'.>9XJGRWF9T!#=M"% MAHV2([RI1',6!"5KM!SLC.?V[%D$??YSH#']I2"PH3H)'1P1%$(J_2AS<';$ M\QNNA,K!N;HZ1Y@-'-#0:Y8J8"U.T(M:]@)"Z*@%QT\US%P\,Y3]<,8,-IH+ M4=ISA^@T2@1Y_6AG0$#`-.#(!0IP,@CLD`9R?PYG^R&5J9`KHU&7`0^O_$P9 MD,L7.H1P,O,!@1O"W)^Y[`?:*L345-3`*-:(T`T*N(.?B0UNE'X4#C8A0QW& MBUM\O.0]'>GT73J)AVZ^ M#^J')OL!^IYJURM">9T,8$\Z`L<^O;(%\.QIE[K6VSZMY,&]T.L+\-Q50N!$ M-LRU0X>"WRF:QL=&P>\8+OSQI.!W&O/2T'.DXWA"0D\='"3_&VMO> M\KFOUH?:VE[7XUZN^]EK*H>N8./CN+%;3UUDG1_\UD8_4[ZO_.F1#X+?+C]U MP:4^]T-.]]1!7/R!+5'FA9G]S[\^^,A=/QO:?WL<%\$)5"B"%/C^V"842N4` MF"AW`!%E$"DO=R0QIR0\4G,M)R\4B`0QB%`/0X%)D(2B=X)`V(%*D(2J!X4TZ((-D80@ MJ"T4"",JV#`F""T46#)?6&03&(4@X`1)J'PAB(;EDX$-!VMWI3F4T6TX`P+] MQA],P1UJD1^1(1C'AUPB8AAO8!()]1&U$0=U@#,<-U44R&Q.\50>^%&T<6R' MV!&_,1FQ)`*0V`)/]5$O<1QN<`+5L1!S$1`<`2N7V!&%6(J-PBV)N(ANT(AU M-BB6>(FQR(@TQ!A](8=@)"V"-P7P%C0!EIX`)E$#I>X`6PX62&<1MNL(S,N"M%D&Y/=H'*\8N[ MSo, let's say you have a fairly long file and >you want to globally add a blank line immediately >before every line that begins with a ">" character. > Try the following: :%s/^>/^M>/ where '^M' is generated by entering CONTROL V followed by CONTROL M and '^>' is actually a caret followed by a right chevron. Cheers, Dave P. From ciacovel@telesciences.com (Chris D Iacovelli) Subject: Re: replace with CR? Date: Fri, 5 Feb 1993 15:51:23 GMT In article <1klsekINNk9k@mojo.eng.umd.edu> lind@eng.umd.edu (Charles A. Lind) writes: > >Hi, > I have a line of words in the form: > > joe, pete, ron, mary, rich, nick, ted > > and I would like to change all the ',' to so that > I get > > joe > pete > ron > mary > rich > nick > ted > >I guess something of the form > > :1,$ s/, //g > >is what I am looking for. > >In general I guess I am looking for the representation for , >, etc. I looked in cs.uwp.edu but I could not find this. > >Thanks > >Charles >-- >------------------------------------------------------ > Charles Lind -- lind@eng.umd.edu > Department of Aerospace Engineering > University of MD, College Park, MD 20742 How about this: :1,$s/, /^V^M/g ^^^^ control-v then control-m Works for me. Chris. ================= VI it is not just an editor, it is a number. ================= From zz1bb@impending.ucsd.edu (Barry Brown) Subject: Re: vi? CAPS --> small Date: 5 Feb 93 16:34:26 GMT In <1663@integow.integrity.nl> edwin@integow.integrity.nl (Edwin Koedam) writes: >Charles writes: >: Within vi is there a way to change all capital letters to small >: letters, or vice versa. Is this possible? >To change capital letters into small ones, just use: > :%s/./\l&/g >To change small letters into capital ones, just use: > :%s/./\u&/g Pressing tilde (~) over a character will change its case and advance the cursor to the next character. Just hold down the tilde key and swoop over a few sentences to change all the letters to the opposite case. -- Barry E. Brown -- \ UCSD Instructional Computing Center bebrown@ucsd.{edu,uucp,bitnet} \ Anime Stuff FTP Server administrator Somewhere in San Diego, CA..... \ (ftp network.ucsd.edu [132.239.254.203]) "Stimpy, sometimes your wealth of ignorance astounds me." -- Ren From ciacovel@telesciences.com (Chris D Iacovelli) Subject: Re: Why !! Date: Sun, 7 Feb 1993 15:27:41 GMT In article <1993Feb4.003728.13763@dragon.acadiau.ca> 911288c@dragon.acadiau.ca (EDwin Chung) writes: >Dear friend, > > I still don't find anything work for centre text > in vi !! > Any help ?? > EDwin > EDwin, Try adding this to your .exrc file: ------- snip -------- map [c >>d0$maKV{{\q map K 80a map V 80|D map {{ `a map \q lxd0:s/ / /g$p ------- snip -------- It works for me. cdi. ============================= Christopher D. Iacovelli Member, Technical Staff TeleSciences CO Systems Moorestown, NJ 08057-1177 USA ciacovel@telesciences.com ============================= From popaul@cs.mcgill.ca (Paul TERRAY) Subject: Re: vi? CAPS --> small Date: 10 Feb 93 20:36:13 GMT Reply-To: popaul@binkley.cs.mcgill.ca > In <1663@integow.integrity.nl> edwin@integow.integrity.nl (Edwin Koedam) writes: > >To change small letters into capital ones, just use: > > :%s/./\u&/g For more detail, \u modifier just change the first letter of the match. So if you want all word to begin by a upper case letter: :%s/[a-zA-Z]*/\u&/g otherwise, you can use \U modifier like :%s/.*/\U&/g will change everything to upper case. Paul From nh@cbnewsg.cb.att.com (nicholas.hounsome) Subject: Re: VI with tags stack feature Date: Fri, 12 Feb 1993 11:32:29 GMT >From article <1993Feb11.190457.13940@bnr.ca>, by mschee@bcarh600.bnr.ca (Michael SamChee): > Does any one have access or know of any version of VI for > HP workstations, that has the 'tags stack' feature ? > > ie, you can invoke tags recursively and be able to > pop back to the previously invoked file. > > Thanks very much in advance, > Michael. elvis has tagstack and I believe that it is supposed to work on HP. From watts@cs.scarolina.edu (Chris Watts) Subject: Changing case of a word.... Date: 12 Feb 93 02:07:37 GMT Could anyone out there tell me how to change the case of a single word to all upper case or all lower case. I would like to do this for a single word not all the words in the document. I would appreciate any feedback. Thanks. Chris From dattier@genesis.MCS.COM (DWT) Subject: Re: ctrl-d in vi's insert mode Date: 9 Mar 1993 16:04:47 -0600 Reply-To: dattier@genesis.mcs.com (David W. Tamkin) eleleetk@nuscc.nus.sg (Teng-Kiat Lee) wrote in <1993Mar9.041852.13666@nuscc.nus.sg>: | I have a problem getting one of the 'standard' vi macro to | work. The macro works in insert mode and it is supposed to | give me a switch structure when I type sw'. The (for tabbing | one 'sw') works but the (for deleting one 'sw') didn't. It | seems like all the macros defined in the .exrc file with the | didn't work as planned. Has any one any idea how this can | be corrected? I am quite sure I did the right macro. The macro | in question is given below: | map! sw' switch () {^M^Tcase : /**/^M^Tbreak;^M^D^D} | p.s: I did a manual mapping while in vi and it worked. Now there is a big clue; commands in .exrc can get rescanned and special characters in them may need extra escaping that they don't need if you define a mapping or map!pinFrom dattier@ddsw1.mcs.com (David W. Tamkin) Subject: Re: set nu Date: Fri, 29 May 1992 02:25:12 GMT [Please post follow-ups to comp.editors.] wiggins@osiris.cso.uiuc.edu (Don Wiggins) wrote in in comp.unix.questions: | Haven't been able to find this anywhere. In vi, ":set nu" numbers the lines | in the file. However, I have never been able to figure out how to | unset this feature, short of getting out of the file and getting back in. :set nonu Here's a hint. In vi, ":set" displays any options you have changed from the defaults, but ":set all" displays the current states of ALL options. If you do ":set all" before ":set nu" you will see "nonumber" in the listing. After ":set nu," ":set" and ":set all" both include "number". After ":set nonu," ":set all" has "nonumber" in it again, and "number" is gone from ":set." So if you want to know how to undo an option, look at :set all before you change it; then you'll see how to change it back. Generally, if an option is a