Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Jan 1999 20:30:04 +1000
From:      "JD" <jasond@ite.net>
To:        <questions@FreeBSD.ORG>
Subject:   Re: replacing ^M in vi
Message-ID:  <199901111031.UAA12182@ite02.ite.net>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901111031.UAA12182>