Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!husc6!think!ames!amdahl!nsc!nsta!instable!amos From: amos@instable.UUCP (Amos Shapir) Newsgroups: comp.unix.wizards Subject: Re: help w/ a vi map Message-ID: <820@instable.UUCP> Date: Wed, 17-Jun-87 11:41:02 EDT Article-I.D.: instable.820 Posted: Wed Jun 17 11:41:02 1987 Date-Received: Sun, 21-Jun-87 10:19:01 EDT References: <7881@brl-adm.ARPA> Reply-To: amos%nsta@nsc.com (Amos Shapir) Distribution: world Organization: National Semiconductor (Israel) Ltd. Home of the 32532 Lines: 25 Summary: Use double escapes in macros Hdate: 20 Sivan 5747 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