有一个文字
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
答案 0 :(得分:45)
您可以使用
:g/word/normal 2dd
这将查找word的所有实例,然后在其后执行命令。在这种情况下,它在正常模式下执行2dd
答案 1 :(得分:20)
答案 2 :(得分:4)
您可以使用:g[lobal]
命令:
:g/This line/norm 3dd
答案 3 :(得分:2)
另一种方式:g
:g/word/norm dj
答案 4 :(得分:0)
你可能想试试这个:
:g/your pattern go here/d