[英]How to delete all lines matching a pattern and a line after in 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
這將查找word的所有實例,然后在其后執行命令。 在這種情況下,它在正常模式下執行2dd
您可以使用:g[lobal]
命令:
:g/This line/norm 3dd
另一種方式:g
:g/word/norm dj
你可能想試試這個:
:g/your pattern go here/d
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.