正则表达式 – 如何在Vim中删除匹配模式和行的所有行?

前端之家收集整理的这篇文章主要介绍了正则表达式 – 如何在Vim中删除匹配模式和行的所有行?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
有一个文字
Title of the text

This line contains a word that is matched by the pattern and it should be deleted.
Next line is supposed to be deleted as well.

Loren ipsum dolorem...

This line contains a word that is matched by the pattern and it should be deleted.
And this one should be deleted

The end of the article

如何删除与第一行匹配的每一行,例如“这行包含一个单词…”和之后的一行。结果是:

Title of the text

Loren ipsum dolorem...

The end of the article
您可以使用
:g/word/normal 2dd

这会找到所有的单词实例,然后执行命令。在这种情况下,它将在正常模式下执行2dd

原文链接:https://www.f2er.com/regex/357424.html

猜你在找的正则表达式相关文章