From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Roodwriter@core.com" Newsgroups: gmane.emacs.help Subject: Re: How to delete ^M Date: Mon, 12 May 2003 02:16:32 -0400 Organization: Posted via Supernews, http://www.supernews.com Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: Reply-To: Roodwriter@core.com NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: main.gmane.org 1052720537 21593 80.91.224.249 (12 May 2003 06:22:17 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 12 May 2003 06:22:17 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Mon May 12 08:22:16 2003 Return-path: Original-Received: from hermes.netfonds.no ([80.91.224.195]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19F6hO-0005bl-00 for ; Mon, 12 May 2003 08:22:16 +0200 Original-Received: from monty-python.gnu.org (monty-python.gnu.org [199.232.76.173]) by hermes.netfonds.no (8.12.8p1/8.12.8) with ESMTP id h4C6Nj5V024761 for ; Mon, 12 May 2003 08:23:45 +0200 (CEST) Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19F6fx-0003Wa-08 for gnu-help-gnu-emacs@m.gmane.org; Mon, 12 May 2003 02:20:41 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: KNode/0.7.1 Original-X-Complaints-To: abuse@supernews.com Original-Lines: 55 Original-Xref: shelby.stanford.edu gnu.emacs.help:113084 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:9579 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:9579 Wang, Zhu wrote: > Hello, > > I am frustrated by a probably very simple problem: > > Each line of a file ended by ^M. I think this is caused by 'ENTER'. How > can I delete them simultaneously? > > Thanks for your help. > > Zhu Wang > > Southern Methodist University It was likely a DOS/Windows file. That ^M is Emacs' way to show a carriage return. There's a slight difference between symbols used to mark the line ends in Linux/unix and DOS/Windows files. Linux/unix uses just a plain newline, which if shown, would be ^J, but usually isn't shown. DOS/Windows uses a carriage return and THEN a newline. Mac, naturally, uses just a carriage return. The easiest way would be to just copy the ^M and then paste it into M-x replace-regexp in the "search" portion. Then put nothing in the "replace" portion. That'll make it go through the file and remove all the carriage returns. You can also use C-q 015 in the "search" portion for the carriage return. That'll give the ASCII equivalent. C-q 012 will find the ^J, if you ever need to do that. C-q 011, incidentally, is for tabs. Since I have a lot of old DOS/Windows text files around, I made macros to convert the line ends--both ways. I bound them to function keys. If you have a lot of these files, and you're on Linux/unix, there are the Todos and Fromdos programs, which will convert the line ends on whole bunches of files. See the man pages. Some programs are sensitive to the line endings. In Windows Notepad, for example, a Linux/unix text file will melt into one huge paragraph. But most programs don't care. They'll adjust and display it correctly. If you're programming something, though, it could make a huge difference. --Rod -- Author of "Linux for Non-Geeks--Clear-eyed Answers for Practical Consumers" and "Boring Stories from Uncle Rod." Both are available at http://www.rodwriterpublishing.com/index.html To reply by e-mail, take the extra "o" out of my e-mail address. It's to confuse spambots, of course.