Hiding ^M in emacs

后端 未结 12 820
陌清茗
陌清茗 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:49

    sudeepdino008's answer did not work for me (I could not comment on his answer, so I had to add my own answer.).

    I was able to fix it using this code:

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

提交回复
热议问题