Hiding ^M in emacs

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

    Like binOr said add this to your %APPDATA%.emacs.d\init.el on windows or where ever is your config.

    ;; Windows EOL
    (defun hide-dos-eol ()
      "Hide ^M in files containing mixed UNIX and DOS line endings."
      (interactive)
      (setq buffer-display-table (make-display-table))
      (aset buffer-display-table ?\^M []))
    
    (defun show-dos-eol ()
      "Show ^M in files containing mixed UNIX and DOS line endings."
      (interactive)
      (setq buffer-display-table (make-display-table))
      (aset buffer-display-table ?\^M ?\^M))
    
    (add-hook 'text-mode-hook 'hide-dos-eol)
    

提交回复
热议问题