如何在 Emacs 中用换行符替换字符? [英] How can I replace a character with a newline in Emacs?
本文介绍了如何在 Emacs 中用换行符替换字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 replace-string
和/或 replace-regexp
替换一个字符 - 比如 ;
- 用一个新行
I am trying to replace a character - say ;
- with a new line using replace-string
and/or replace-regexp
in Emacs.
我尝试了以下命令:
Mx
replace-string
RET;
RET
M-x
replace-string
RET;
RET
这会将 ;
替换为两个字符:
.
This will replace ;
with two characters:
.
Mx replace-regex
RET ;
RET
M-x replace-regex
RET ;
RET
这会导致以下错误(显示在迷你缓冲区中):
This results in the following error (shown in the minibuffer):
在替换文本中无效使用了`'.
Invalid use of `' in replacement text.
在这个任务中使用 replace-string
有什么问题?还有其他方法吗?
What's wrong with using replace-string
for this task? Is there another way to do it?
推荐答案
Mx replace-string
RET ;
RET Cq Cj.
C-q for
quoted-insert
,
C-j 是换行符.
这篇关于如何在 Emacs 中用换行符替换字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文