From owner-freebsd-questions Mon Jan 11 02:32:31 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id CAA12360 for freebsd-questions-outgoing; Mon, 11 Jan 1999 02:32:31 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from ite02.ite.net (ite02.ite.net [205.230.132.3]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id CAA12354 for ; Mon, 11 Jan 1999 02:32:28 -0800 (PST) (envelope-from jasond@ite.net) Received: from jd (ppp043.B.ite.net [208.202.119.43]) by ite02.ite.net (8.9.1/8.9.1) with ESMTP id UAA12182 for ; Mon, 11 Jan 1999 20:31:53 +1000 (GMT) Message-Id: <199901111031.UAA12182@ite02.ite.net> From: "JD" To: Subject: Re: replacing ^M in vi Date: Mon, 11 Jan 1999 20:30:04 +1000 X-MSMail-Priority: Normal X-Priority: 3 X-Mailer: Microsoft Internet Mail 4.70.1155 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In vi control characters are specified by using CTRL-V, then the needed character. To get a ^M inside vi you would need CTRL-V then M. :g /^^M$/d :1,$ s/^M//g First command will delete all line that have only the ^M and nothing else. The second command will delete only the ^M on lines that have other text on them. These commands will work with vi, ed and sed it should be very simple to write a script to strip those control characters out of the text. Jason DeBoni Yigo,Guam ---------- > From: charon@freethought.org > To: questions@FreeBSD.ORG > Subject: replacing ^M in vi > Date: Monday, January 11, 1999 4:59 PM > > Whenever I save a plain text file in WinNT and open it in FreeBSD, at the > end of every line is a "^M". How do I get rid of these? I tried writing a > little C++ program to copy all text except "^M" to another file, but it > doesn't work because C++ treats the ^ and the M as different characters, > whereas vi treats them as _one_ character. After searching the mailing > list archives, I came up with the syntax ":%s/stuff/other stuff/g" as the > oh-so-intuitive replace command in vi, and I tried it, but to no avail (it > says "no match found"). Any suggestions? Thanks, > > > > Charon@freethought.org > http://members.home.net/tuathadedanann/ > > alt.sex.fetish.hamster.duct-tape > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message