Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Jan 2004 10:17:53 -0500
From:      Dan Welch <>
To:        marlon corleone <>
Subject:   Re: how to get rid of ^M character using vi
Message-ID:  <>
In-Reply-To: <>
References:  <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Sun, Jan 25, 2004 at 09:43:21AM +0000, marlon corleone wrote:
> how do i get rid of this annoying character ^M using vi, in pico i used the 
> arguments '-w'
> but what about in vi?

This colon (ed) command works in FreeBSD's included vi's
command mode:


followed by pressing Enter.  The ^M (or Ctrl-M) typed to
show it here should actually be entered by pressing ^v
^M in sequence. (The ^v preface tells vi to use the next
keystroke literally instead of taking it as a command.)

In a slight variation  you can take advantage the
replacement field in the substitution (which I left blank)
to produce a blank line between the original lines --
useful when the ^M marks the paragraph breaks:


It looks redundant, but after playing with the first version
you'll probably see what's going on.

You may also find the following short-cut useful for simpler
i.e., press Enter just after getting the ^M on the command
line, thus ending prematurely.  This works quite usefully
when the file has only one ^M per line and none embedded.

Want to link to this message? Use this URL: <>