From owner-freebsd-questions@FreeBSD.ORG Sun Jan 25 07:37:50 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EA08416A4CE for ; Sun, 25 Jan 2004 07:37:50 -0800 (PST) Received: from pintail.mail.pas.earthlink.net (pintail.mail.pas.earthlink.net [207.217.120.122]) by mx1.FreeBSD.org (Postfix) with ESMTP id AB18443D2D for ; Sun, 25 Jan 2004 07:37:49 -0800 (PST) (envelope-from welchdw@earthlink.net) Received: from user-2ivfa8a.dialup.mindspring.com ([165.247.169.10] helo=gandalf.welch.net) by pintail.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 1AkmKX-00023n-00; Sun, 25 Jan 2004 07:37:46 -0800 Received: from gandalf.welch.net (localhost [127.0.0.1]) by gandalf.welch.net (8.12.6/8.12.6) with ESMTP id i0PFbh0J001922; Sun, 25 Jan 2004 10:37:43 -0500 (EST) (envelope-from welchdw@gandalf.welch.net) Received: (from welchdw@localhost) by gandalf.welch.net (8.12.6/8.12.6/Submit) id i0PFHsc2001885; Sun, 25 Jan 2004 10:17:54 -0500 (EST) Date: Sun, 25 Jan 2004 10:17:53 -0500 From: Dan Welch To: marlon corleone Message-ID: <20040125151753.GA1798@gandalf.welch.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i cc: misc@openbsd.org cc: freebsd-questions@freebsd.org Subject: Re: how to get rid of ^M character using vi X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Dan Welch List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jan 2004 15:37:51 -0000 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: :%s/^M//g 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: :%s/^M/^M/g 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 files: :%s/^M 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.