Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!ll-xn!ames!oliveb!intelca!mipos3!omepd!littlei!ogcvax!schaefer From: schaefer@ogcvax.UUCP (Barton E. Schaefer) Newsgroups: comp.unix.questions Subject: Re: Invisible Ascii with VI Message-ID: <1437@ogcvax.UUCP> Date: Fri, 2-Oct-87 13:44:25 EDT Article-I.D.: ogcvax.1437 Posted: Fri Oct 2 13:44:25 1987 Date-Received: Thu, 8-Oct-87 07:26:47 EDT References: <258@unx1.UUCP> Reply-To: schaefer@ogcvax.UUCP (Barton E. Schaefer) Organization: Oregon Graduate Center, Beaverton, OR Lines: 40 In article was@hplsdlw.HP.COM (William A. Stubblebine) writes: }> / hplsdlw:comp.unix.questions / andy@unx1.UUCP (Andy Clews): }> Does anyone out there know if it's possible to insert/search/replace }> non-printing ascii characters? }> Specifically: I sometimes get files from a net source that have an "extra" }> CR tacked on the end of the line ... }[ Some explanation of how to do this deleted ] } }Unfortunately, many versions if ex/vi have a bug in handling ^M as a }replacement pattern via ex while in visual mode. That is, typing } :s/;/\^M/g }to change } hello;goodbye }into } hello } goodbye }while in visual mode doesn't work. The ^M isn't interpreted as the }replacement pattern, it just terminates the command. The way to get around problems like this is to use double ^V characters; that is, you type :s/;/^V^V^V^M/g^M (you use the RETURN key instead of CTRL-M) which echoes as :s/;/^V^M/g The first ^V assures that the second ^V will be passed on to the ex substitute command after vi-interface parsing; the third ^V escapes the ^M so it isn't interpreted as the end of the command. The ex substitute command then sees the ^V^M sequence and interprets it as a literal ^M. I don't know if this works on versions that interpret a backslash-escaped ^M "correctly", but it works for me (UNIX 4.3 BSD). -- Bart Schaefer CSNET: schaefer@Oregon-Grad UUCP: ...{tektronix,verdix}!ogcvax!schaefer "This area is like heaven, and they want to turn it into California." -- Joseph Cook, Amish farmer, protesting highway construction