Thus, my question is:
Is there a way to tell emacs not to show the ^M character altogether?
Thanks for any help,
/Ola
IME this is only a problem when line endings in a file are not consistent.
so my advice would be to make sure each file only has one kind of line
ending, then emacs will simply detect the format correctly and will tell
you in the mode line you're editing a DOS file, and won't show the ^M
characters.
--
Joost Kremers joostk...@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
This should happen automatically, unless you have a file with
inconsistent lineendings: some with ^M, others without. Typing "C-x
RET c dos RET" immediately before "C-x C-f" that you use to visit the
file will cause Emacs to not display any ^M characters, even if the
lineendings are inconsistent, but if you edit that file and save it,
Emacs will add a ^M character to each line when it saves the file,
which might not be what you want in this case.
IOW, Emacs cannot remember whether there should be a ^M character on a
line by line basis, only for the whole file.
> olgo wrote:
>> I keep reading solutions to this problem by means of substituting the
>> line endings with a global replace but this is not what I need.
>> I need for the files to be kept as they are, with all kinds of line
>> endings, but I don't want to see it in the editor.
>>
>> Thus, my question is:
>> Is there a way to tell emacs not to show the ^M character altogether?
>
> IME this is only a problem when line endings in a file are not consistent.
> so my advice would be to make sure each file only has one kind of line
> ending, then emacs will simply detect the format correctly and will tell
> you in the mode line you're editing a DOS file, and won't show the ^M
> characters.
I use the following function to remove the trailing ^M from such files:
(defun xsteve-remove-control-M ()
"Remove ^M at end of line in the whole buffer."
(interactive)
(save-match-data
(save-excursion
(let ((remove-count 0))
(goto-char (point-min))
(while (re-search-forward "
$" (point-max) t)
(setq remove-count (+ remove-count 1))
(replace-match "" nil nil))
(message (format "%d ^M removed from buffer." remove-count))))))
Stefan.
** Posted from http://www.teranews.com **
M-x replace-string RET C-q RET RET RET
or
C-M-% C-q RET RET RET !