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

标签 search replace emacs

如何查找和删除以文本 in 开头的行?

我使用命令 C-M-s ^in查找以 in 开头的所有行,但后来我真的不知道该怎么办。

最佳答案

M-x flush-lines RET ^in RET
C-h f flush-lines告诉你:

flush-lines is an interactive compiled Lisp function in replace.el.

It is bound to menu-bar edit flush-lines.

(flush-lines REGEXP &optional RSTART REND INTERACTIVE)

Delete lines containing matches for REGEXP.

When called from Lisp (and usually when called interactively as well, see below), applies to the part of the buffer after point. 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.

Second and third arg RSTART and REND specify the region to operate on. 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.

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.

关于search - Emacs:如何删除以特定文本开头的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47561988/

相关文章:

c - 为什么不增加?

java - 即使字符串与 Java 匹配,compareTo 也会返回 -1

Javascript 替换不适用于 jQuery

xcode - 我应该从 Vim 切换到 Emacs,如果是的话,有什么建议吗?

emacs - (读取命令...)在空白输入时返回奇怪的对象

mysql - 您如何通过全文 boolean 搜索来查找术语 C++?

arrays - 为什么在 HashMap 中查找项目比在数组中查找项目更快?

xml - 找不到 XSLT 替换函数

regex - 如何通过第一个 "testing"或 "preview"搜索部分在 Vim 中有效地搜索和替换?

xpath - 如何在 emacs nxml-mode 中搜索与 xpath 表达式匹配的元素?