Bru*_*ens 74
Mx replace-string Cq Cj RET RET
诀窍是引用Cj,但否则替换换行就像替换其他任何内容.
Pet*_*te 14
我的密钥绑定,我认为是标准的,在Windows上:
选择地区
移 - 交替%
ctrl-Q ctrl-J
返回
返回
!
或者换句话说,查询替换区域,ctrl-q获取扩展字符,ctrl-j放入换行符,替换为nothing,all all.
Mar*_*air 11
如果你想创建一个函数来执行此操作(并将其绑定到F8),您可以尝试:
(defun remove-newlines-in-region ()
"Removes all newlines in the region."
(interactive)
(save-restriction
(narrow-to-region (point) (mark))
(goto-char (point-min))
(while (search-forward "\n" nil t) (replace-match "" nil t))))
(global-set-key [f8] 'remove-newlines-in-region)
Run Code Online (Sandbox Code Playgroud)
这是基于我在这里找到的一个例子.