Hiding ^M in emacs

后端 未结 12 816
陌清茗
陌清茗 2020-12-12 12:54

Sometimes I need to read log files that have ^M (control-M) in the line endings. I can do a global replace to get rid of them, but then something more is logged to the log

12条回答
  •  [愿得一人]
    2020-12-12 13:27

    Put this in your .emacs:

    (defun dos2unix ()
      "Replace DOS eolns CR LF with Unix eolns CR"
      (interactive)
        (goto-char (point-min))
          (while (search-forward "\r" nil t) (replace-match "")))
    

    Now you can simply call dos2unix and remove all the ^M characters.

提交回复
热议问题