Vim 搜索模式,如果发生则删除到行尾 [英] Vim search for a pattern and if occurs delete to end of line
本文介绍了Vim 搜索模式,如果发生则删除到行尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在文本文件中搜索特定模式.如果出现这种模式,则意味着不需要该行的其余部分,因此可以删除.
I am trying to search a text file for a certain pattern. If this pattern occurs then it means that the rest of the line is not needed and therefore can be deleted.
我曾尝试使用以下命令,但到目前为止都没有成功.
I have tried using the following commands, but so far have been unsuccessful.
:%s/{pattern}/d$
:g/{pattern}/d$
如果有人有任何建议,他们将不胜感激
If anyone has any suggestions they would be greatly appreciated
推荐答案
:%s/{pattern}.*//
会起作用吗?
这篇关于Vim 搜索模式,如果发生则删除到行尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文