all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bob Proulx <bob@proulx.com>
To: peaches20 <watson1724@comcast.net>
Cc: Help-gnu-emacs@gnu.org
Subject: Re: Removing control M
Date: Fri, 28 Feb 2014 14:01:14 -0700	[thread overview]
Message-ID: <20140228210114.GA6843@hysteria.proulx.com> (raw)
In-Reply-To: <1393618592227-315636.post@n5.nabble.com>

peaches20 wrote:
> I've transferred several dos files to unix.  I now have the control M at tne
> end of the line.  How does one remove this globally.  I tried the dos2unis
> but that is not in my emacs commands. 

There are several different strategies for dealing with changing line
ending conventions.  One is "dos2unix".  That is a command line
program unrelated to emacs.  You use it on the command line to filter
the file from one to the other.  If you don't have dos2unix installed
then you can simply use 'tr' to do so.

  tr -d '\015\032' < input.txt >output.txt

Inside emacs for an internal emacs solution there are several
strategies.  One is to visit the file without any content conversion
at all.  Then the ^M and ^Z characters show up as literal characters
and may be deleted.  This is brute force but simple to understand and
I still do it the most often when I need this.

  M-x find-file-literally
    Visit a file with no conversion of the contents.

  M-x replace-string <RET> STRING <RET> NEWSTRING <RET>
    Using ^q^m as the string to replace

But perhaps the most elegant way is to use the emacs coding system to
do this.  You can specify the coding system to use and specify unix
file coding when you save the file.

  C-x <RET> c unix <RET>
  C-x C-s

Modify the file first to make sure it is modified so that it will be
saved.  You can mark a buffer as modified explicitly using the
not-modified key M-~ with an argument.  The full sequence looks like
this sequence.

  C-u M-~
  C-x <RET> c unix <RET>
  C-x C-s

The above is probably the most emacs way of doing this inside emacs.
But there isn't anything wrong with using 'tr' or 'dos2unix' or
whatever on the file outside of emacs.  Whatever.

If you need to convert character encodings then that is an additional
need.  Please say so explicitly.  The "iconv" program is a tool that
can be used to convert almost any encoding to another one.

  iconv -f CP1252 -t UTF-8 < infile.txt > outfile.txt

Bob



  parent reply	other threads:[~2014-02-28 21:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-28 20:16 Removing control M peaches20
2014-02-28 20:40 ` Jai Dayal
2014-02-28 20:43   ` peaches20
2014-02-28 20:44     ` Jai Dayal
2014-02-28 21:01 ` Bob Proulx [this message]
     [not found] ` <mailman.16317.1393620062.10748.help-gnu-emacs@gnu.org>
2014-02-28 21:25   ` Dan Espen
2014-02-28 21:44     ` Mike Ray
2014-03-01  7:55     ` Eli Zaretskii
2014-03-01  8:31       ` Yuri Khan
2014-03-01  9:00         ` Eli Zaretskii
     [not found]     ` <mailman.16341.1393660562.10748.help-gnu-emacs@gnu.org>
2014-03-01 15:45       ` Dan Espen
2014-03-12 14:26 ` Ken Goldman
     [not found] <mailman.16316.1393619959.10748.help-gnu-emacs@gnu.org>
2014-02-28 23:02 ` Joe Fineman

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=20140228210114.GA6843@hysteria.proulx.com \
    --to=bob@proulx.com \
    --cc=Help-gnu-emacs@gnu.org \
    --cc=watson1724@comcast.net \
    /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.