groff%community-chest.mitre.org@gateway.mitre.ORG (06/17/87)
I have encountered a puzzling problem w/ setting up a map in vi. It began w/ a file I had redirected from 'man printcap'. This file had _^H's thru-out. I could have simply done :1,$s/_^H//g and gone merrily on my way. (This worked fine.) I decided to create a map for this function by doing :map ^R :1,$s/_^H//g^M - this worked SORT OF, but NOT as I would have expected. (Control characters and carriage return are escaped w/ ^V.) The puzzling sequence follows: (starting w/ file full of _^H's) 1) Issue the command longhand (works) 2) Undo the command ('u') 3) Issue the map command - ^R (works) 4) Undo the command, and quit the file (no changes) 5) BTW the map setup is in my EXINIT variable 6) 'vi' the file again and immediately issue the map command. 7) Get the error: "No previous regular expression" Would really appreciate enlightenment from anyone who understands what is happening. - Paul Groff groff@mitre.arpa The MITRE Corporation 7525 Colshire Dr. McLean, VA 22102 (703) 883-5810
amos@instable.UUCP (Amos Shapir) (06/17/87)
In article <7881@brl-adm.ARPA> groff%community-chest.mitre.org@gateway.mitre.ORG writes: > I have encountered a puzzling problem w/ setting up a map in vi. >It began w/ a file I had redirected from 'man printcap'. This file had >_^H's thru-out. I could have simply done :1,$s/_^H//g and gone merrily >on my way. (This worked fine.) I decided to create a map for this function >by doing :map ^R :1,$s/_^H//g^M - this worked SORT OF, but NOT as I would have >expected. (Control characters and carriage return are escaped w/ ^V.) What happens is that you used ^V to escape the ^H when you *created* the macro; when you *executed* it, vi got an un-escaped ^H which erased the _ resulting in the command :1,$s///g which uses the latest r.e. used, which just happened to be the same since you tried the same command before manually. The correct way is to insure a ^V gets into the macro by doing :map ^R :1,$s/_^V^V^V^H//g^V^M which puts into the macro :1,$s/_^V^H//g^M which does what you mean. This triple-esacpe in macro definition is well known to anyone who ever tried to program [nt]roff. -- Amos Shapir National Semiconductor (Israel) 6 Maskit st. P.O.B. 3007, Herzlia 46104, Israel Tel. (972)52-522261 amos%nsta@nsc.com @{hplabs,pyramid,sun,decwrl} 34 48 E / 32 10 N
leder@ihlpm.ATT.COM (Leder) (06/17/87)
In article <7881@brl-adm.ARPA>, groff%community-chest.mitre.org@gateway.mitre.ORG writes: > > ....[ deleted some prose ] .... > > 6) 'vi' the file again and immediately issue the map command. > 7) Get the error: "No previous regular expression" > The problem is that the EXINIT or .exrc file is handled (as best I can tell from experience) as a keystroke file and should include the ^V's that you had to type in at the command line. Good Luck, Bob Leder - it's my opinion and it's worth what it cost you
rjd@tiger.UUCP (06/18/87)
> on my way. (This worked fine.) I decided to create a map for this function > by doing :map ^R :1,$s/_^H//g^M - this worked SORT OF, but NOT as I would > have expected. (Control characters and carriage return are escaped w/ ^V.) > > The puzzling sequence follows: (starting w/ file full of _^H's) > 1) Issue the command longhand (works) > 2) Undo the command ('u') > 3) Issue the map command - ^R (works) > 4) Undo the command, and quit the file (no changes) > 5) BTW the map setup is in my EXINIT variable > 6) 'vi' the file again and immediately issue the map command. > 7) Get the error: "No previous regular expression" > > - Paul Groff I try to always use ununsed vi commands for my map's. This probably is not the cause for your problem, but it could have some effect. From looking in the various manuals on vi around, I once made a list of unused vi commands by noting all letters that I could not find a command use for and have it posted in my office at work. For those who are interested, the unused vi single letter commands *I* have are: g q v K V \ _ ^A ^C ^K ^O ^S ^X ^\ ^_ * (control chars denoted by ^) (did not say it was possible to type each, just what they were). The ^R you mention is in my manual for a command on "dumb" temrinals to refresh lines, so maybe there is a confusing conflict. BTW-Any corrections to my list are welcome. Randy UUCP:(ihnp4!)3b2fst!randy
wtm@bunker.UUCP (Bill McGarry) (06/19/87)
In article <7881@brl-adm.ARPA> groff@gateway.mitre.ORG writes (edited): > > > I have encountered a puzzling problem w/ setting up a map in vi. >It began w/ a file I had redirected from 'man printcap'. This file had >_^H's thru-out. I could have simply done :1,$s/_^H//g and gone merrily >on my way. (This worked fine.) I decided to create a map for this function >by doing :map ^R :1,$s/_^H//g^M - this worked SORT OF, but NOT as I would have >expected. I get the error: "No previous regular expression" > There are two problems here: First, the "$" should be escaped as "\$" to avoid any problem with shell variables. Secondly, control V's (or your "literal-next" character) must be included in the map itself. The final map should look like this: :map ^R :1,\$s/_^V^V^H//g^M Note that to get the "^V^V^H" sequence, you must actually type: ^V^V^V^V^V^H (That's right -- 5 ^V's and 1 ^H) Looks weird but it works (I tried it) and it does make sense. The first control V allows the next control V to "get through" to vi so that the control H will not act as a backspace. Otherwise, the map actually ends up being: ":1,///g" Bill McGarry PATH: {philabs, decvax, fortune, yale}!bunker!wtm
dave@astra.necisa.oz (Dave Horsfall) (06/25/87)
My two cents worth: Also make sure you don't have "beautify" (bf) set in your EXINIT variable BEFORE your nice little binary characters! "Beautify" will happily strip them out for you. If you do have "set bf", make it LAST on the string. This took me AGES to find! Try it sometime. -- Dave Horsfall (VK2KFU) TEL: +61 2 438-3544 FAX: +61 2 439-7036 NEC Information Systems Aust. ACS: dave@astra.necisa.oz (also CSNET) 3rd Floor, 99 Nicholson St ARPA: dave%astra.necisa.oz@seismo.css.gov St. Leonards NSW 2064 UUCP: {enea,hplabs,mcvax,prlb2,seismo,ukc}!\ AUSTRALIA munnari!astra.necisa.oz!dave