y***g 发帖数: 6 | 1 How about command" dos2unix" | c*****t 发帖数: 1879 | 2 hoho, 除了用 dos2unix 外, 在 emacs 里去掉 ^M 也很容易.
首先到第一行末尾, 在 ^M 前, 打 ^k (Ctrl-k) 将 ^M 吃掉.
然后打 M-x replace-string (enter) 进入 search/replace
mode, 然后打 ^y 把 ^M 给 paste 进去, 再连打两个 (enter)
key 就行了.
在 search/replace mode 里使用 ^y 可以将多行文字, 包括
^M, ^J 等删掉. | b**s 发帖数: 67 | 3 put following in your .emacs
(global-set-key [f5] 'cut-ctrlM) ; cut all ^M.
;; prevent echoing ^M in the shell (a hard one)
(add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t)
;if you encounter a file with ^M or ... at the end of every line,
;this means a worng copy by samba or floppy disk of the DOS file to UNIX.
;get rid of them by pressing [F5]
(defun cut-ctrlM ()
"Cut all visible ^M."
(interactive)
(beginning-of-buffer)
(while (search-forward "\ |
|