如何用Emacs中的换行符替换一个字符? [英] How to replace a character with a newline in Emacs?

查看:116
本文介绍了如何用Emacs中的换行符替换一个字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用替换字符串替换一个字符 - 例如; 在Emacs中替换regexp



我尝试过以下命令:




  • Mx replace-string RET code>; RET \\\



    这将用2个字符替换; \\\


  • Mx replace-regex RET ; RET \\\



    这会导致以下错误显示在minibuffer中):


    替换文本中使用\无效。





使用 replace-string 为此任务?还有其他方式吗?



谢谢。

解决方案

Mx replace-string kbd> RET ; RET Cq Cj




  • Cq for quoted-insert


  • Cj 是一个换行符。




干杯! / p>

I am trying to replace a character - say ; - with a new line using replace-string and/or replace-regexp in Emacs.

I have tried the following commands:

  • M-x replace-string RET ; RET \n

    This will replace ; with 2 characters: \n.

  • M-x replace-regex RET ; RET \n

    This results in the following error (shown in the minibuffer):

    Invalid use of `\' in replacement text.

What's wrong with using replace-string for this task? Is there any other way to do it?

Thanks.

解决方案

M-x replace-string RET ; RET C-q C-j.

  • C-q for quoted-insert,

  • C-j is a newline.

Cheers!

这篇关于如何用Emacs中的换行符替换一个字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆