unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to delete ^M
@ 2003-05-12  5:45 Wang, Zhu
  0 siblings, 0 replies; 8+ messages in thread
From: Wang, Zhu @ 2003-05-12  5:45 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to delete ^M
       [not found] <mailman.5996.1052718263.21513.help-gnu-emacs@gnu.org>
@ 2003-05-12  6:16 ` Roodwriter
  2003-05-12  6:24   ` Stein A. Stromme
  2003-05-12 22:20 ` Joe Fineman
  2003-05-12 22:59 ` Eric Hanchrow
  2 siblings, 1 reply; 8+ messages in thread
From: Roodwriter @ 2003-05-12  6:16 UTC (permalink / raw)


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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to delete ^M
  2003-05-12  6:16 ` How to delete ^M Roodwriter
@ 2003-05-12  6:24   ` Stein A. Stromme
  2003-05-12  6:39     ` Roodwriter
  0 siblings, 1 reply; 8+ messages in thread
From: Stein A. Stromme @ 2003-05-12  6:24 UTC (permalink / raw)


[Roodwriter@core.com]

| You can also use C-q 015 in the "search" portion for the carriage return. 

C-q C-m is quicker, and you don't have to remember the number.
-- 
Stein Arild Strømme            +47 55584825, +47 95801887
Universitetet i Bergen                  Fax: +47 55589672     
Matematisk institutt                www.mi.uib.no/stromme         
Johs Brunsg 12, N-5008 BERGEN           stromme@mi.uib.no

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to delete ^M
  2003-05-12  6:24   ` Stein A. Stromme
@ 2003-05-12  6:39     ` Roodwriter
  0 siblings, 0 replies; 8+ messages in thread
From: Roodwriter @ 2003-05-12  6:39 UTC (permalink / raw)


Stein A. Stromme wrote:

> [Roodwriter@core.com]
> 
> | You can also use C-q 015 in the "search" portion for the carriage
> | return.
> 
> C-q C-m is quicker, and you don't have to remember the number.

Probably a better plan. I had to look up the number.

Having a macro do your work for you will do that to you.

--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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to delete ^M
       [not found] <mailman.5996.1052718263.21513.help-gnu-emacs@gnu.org>
  2003-05-12  6:16 ` How to delete ^M Roodwriter
@ 2003-05-12 22:20 ` Joe Fineman
  2003-05-12 22:59 ` Eric Hanchrow
  2 siblings, 0 replies; 8+ messages in thread
From: Joe Fineman @ 2003-05-12 22:20 UTC (permalink / raw)


"Wang, Zhu" <zhuw@mail.smu.edu> writes:

> Each line of a file ended by ^M. I think this is caused by
> 'ENTER'. How can I delete them simultaneously?

I have found the following tool useful:

(defun ridm ()
  "Remove intrusive CTRL-Ms from the buffer"
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (replace-string "\C-m\C-j" "\C-j")))
-- 
---  Joe Fineman    jcf@TheWorld.com

||:  Be inobviously tuitive.  ||

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to delete ^M
       [not found] <mailman.5996.1052718263.21513.help-gnu-emacs@gnu.org>
  2003-05-12  6:16 ` How to delete ^M Roodwriter
  2003-05-12 22:20 ` Joe Fineman
@ 2003-05-12 22:59 ` Eric Hanchrow
  2 siblings, 0 replies; 8+ messages in thread
From: Eric Hanchrow @ 2003-05-12 22:59 UTC (permalink / raw)



    Each line of a file ended by ^M. I think this is caused by
    'ENTER'. How can I delete them simultaneously?

Here's what I use:

    (defun strip ()
      "Ensures that when the current buffer is saved, lines will not end
    with carriage returns.  Does so by setting the coding system to
    raw-text-unix."
      (interactive)
      (set-buffer-file-coding-system 'raw-text-unix))

-- 

      |\      _,,,---,,_
ZZZzz /,`.-'`'    -.  ;-;;,_
     |,4-  ) )-,_. ,\ (  `'-'
    '---''(_/--'  `-'\_) fL
        -- Igor Pechtchanski

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: How to delete ^M
@ 2003-05-13  2:53 Wang, Zhu
  0 siblings, 0 replies; 8+ messages in thread
From: Wang, Zhu @ 2003-05-13  2:53 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 951 bytes --]

Thanks,
 
Zhu Wang

	-----Original Message----- 
	From: Eric Hanchrow [mailto:offby1@blarg.net] 
	Sent: Mon 5/12/2003 5:59 PM 
	To: help-gnu-emacs@gnu.org 
	Cc: 
	Subject: Re: How to delete ^M
	
	


	    Each line of a file ended by ^M. I think this is caused by
	    'ENTER'. How can I delete them simultaneously?
	
	Here's what I use:
	
	    (defun strip ()
	      "Ensures that when the current buffer is saved, lines will not end
	    with carriage returns.  Does so by setting the coding system to
	    raw-text-unix."
	      (interactive)
	      (set-buffer-file-coding-system 'raw-text-unix))
	
	--
	
	      |\      _,,,---,,_
	ZZZzz /,`.-'`'    -.  ;-;;,_
	     |,4-  ) )-,_. ,\ (  `'-'
	    '---''(_/--'  `-'\_) fL
	        -- Igor Pechtchanski
	_______________________________________________
	Help-gnu-emacs mailing list
	Help-gnu-emacs@gnu.org
	http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
	


[-- Attachment #2: Type: text/plain, Size: 151 bytes --]

_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnu-emacs

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: How to delete ^M
@ 2003-05-13  2:54 Wang, Zhu
  0 siblings, 0 replies; 8+ messages in thread
From: Wang, Zhu @ 2003-05-13  2:54 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 837 bytes --]

Thanks,
 
Zhu Wang

	-----Original Message----- 
	From: Joe Fineman [mailto:jcf@TheWorld.com] 
	Sent: Mon 5/12/2003 5:20 PM 
	To: help-gnu-emacs@gnu.org 
	Cc: 
	Subject: Re: How to delete ^M
	
	

	"Wang, Zhu" <zhuw@mail.smu.edu> writes:
	
	> Each line of a file ended by ^M. I think this is caused by
	> 'ENTER'. How can I delete them simultaneously?
	
	I have found the following tool useful:
	
	(defun ridm ()
	  "Remove intrusive CTRL-Ms from the buffer"
	  (interactive)
	  (save-excursion
	    (goto-char (point-min))
	    (replace-string "\C-m\C-j" "\C-j")))
	--
	---  Joe Fineman    jcf@TheWorld.com
	
	||:  Be inobviously tuitive.  ||
	_______________________________________________
	Help-gnu-emacs mailing list
	Help-gnu-emacs@gnu.org
	http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
	


[-- Attachment #2: Type: text/plain, Size: 151 bytes --]

_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnu-emacs

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-05-13  2:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.5996.1052718263.21513.help-gnu-emacs@gnu.org>
2003-05-12  6:16 ` How to delete ^M Roodwriter
2003-05-12  6:24   ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).