all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Roodwriter@core.com" <Roodwriter@core.com>
Subject: Re: How to delete ^M
Date: Mon, 12 May 2003 02:16:32 -0400	[thread overview]
Message-ID: <vbuf2rg2vi7t22@corp.supernews.com> (raw)
In-Reply-To: mailman.5996.1052718263.21513.help-gnu-emacs@gnu.org

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.

       reply	other threads:[~2003-05-12  6:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.5996.1052718263.21513.help-gnu-emacs@gnu.org>
2003-05-12  6:16 ` Roodwriter [this message]
2003-05-12  6:24   ` How to delete ^M Stein A. Stromme
2003-05-12  6:39     ` Roodwriter
2003-05-12 22:20 ` Joe Fineman
2003-05-12 22:59 ` Eric Hanchrow
2003-05-13  2:54 Wang, Zhu
  -- strict thread matches above, loose matches on Subject: below --
2003-05-13  2:53 Wang, Zhu
2003-05-12  5:45 Wang, Zhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vbuf2rg2vi7t22@corp.supernews.com \
    --to=roodwriter@core.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.