加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 06:34:11 所属栏目:百科 来源:网络整理
导读:有一个文字 Title of the textThis 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
有一个文字
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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读