简体   繁体   English

Emacs:如何删除以特定文本开头的行

[英]Emacs: How to delete a line starting with specific text

How can I find and delete lines which start with the text in ? 我如何才能找到并删除与文本行开始in

I use the command CMs ^in to find all lines starting with in , but then I don't really know what to do. 我使用命令CMs ^in来查找以in开头的所有行,但后来我真的不知道该怎么做。

Mx flush-lines RET ^in RET

Ch f flush-lines tells you: Ch f flush-lines告诉你:

flush-lines is an interactive compiled Lisp function in replace.el . flush-linesreplace.el的交互式编译Lisp函数。

It is bound to menu-bar edit flush-lines . 它被绑定到menu-bar edit flush-lines

(flush-lines REGEXP &optional RSTART REND INTERACTIVE)

Delete lines containing matches for REGEXP . 删除包含REGEXP匹配的行。

When called from Lisp (and usually when called interactively as well, see below), applies to the part of the buffer after point. 从Lisp调用时(通常在交互式调用时,见下文),在点之后应用于缓冲区的一部分。 The line point is in is deleted if and only if it contains a match for regexp starting after point. 当且仅当它包含与点之后开始的正则表达式匹配时,才删除行点。

If REGEXP contains upper case characters (excluding those preceded by \\ ) and search-upper-case is non- nil , the matching is case-sensitive. 如果REGEXP包含大写字符(不包括由前面\\ )和search-upper-case是非nil ,匹配是大小写敏感的。

Second and third arg RSTART and REND specify the region to operate on. 第二个和第三个arg RSTARTREND指定要操作的区域。 Lines partially contained in this region are deleted if and only if they contain a match entirely contained in it. 当且仅当它们包含完全包含在其中的匹配时,才会删除此区域中部分包含的行。

Interactively, in Transient Mark mode when the mark is active, operate on the contents of the region. 交互式地,当标记处于活动状态时,在瞬态标记模式下,对该区域的内容进行操作。 Otherwise, operate from point to the end of (the accessible portion of) the buffer. 否则,从缓冲区的点(可访问部分)结束操作。 When calling this function from Lisp, you can pretend that it was called interactively by passing a non-nil INTERACTIVE argument. 从Lisp调用此函数时,您可以通过传递非零INTERACTIVE参数来假装它是以交互方式调用的。

If a match is split across lines, all the lines it lies in are deleted. 如果匹配是跨行分割的,则删除它所在的所有行。 They are deleted before looking for the next match. 查找下一场比赛之前删除它们。 Hence, a match starting on the same line at which another match ended is ignored. 因此,忽略从另一个匹配结束的同一行开始的匹配。

query-replace-regexp "in.*" to "" will be work. query-replace-regexp“in。*”to“”将起作用。 you should not input " to the prompt 你不应该输入“提示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM