Search code examples
windowsunixemacsnewlinecarriage-return

Don't display ^M characters with emacs


I am wondering if there is a way to temporarily not display the ^M characters in a file.
I don't want to remove them I just want to not display them.


Solution

  • I use the following function (forgot where I found it):

    (defun hide-ctrl-M ()
      "Hides the disturbing '^M' showing up in files containing mixed UNIX and DOS line endings."
      (interactive)
      (setq buffer-display-table (make-display-table))
      (aset buffer-display-table ?\^M []))