Redian新闻
>
Re: 为什么emacs自动给我加^M.
avatar
c*t
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 等删掉.
avatar
b*s
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 "\
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。