I have a text file like this:
我有这样的文本文件:
This is sentence 1: text I don't need
This is sentence 2? text I don't need
This is sentence 3? text I don't need
This is sentence 4: text I don't need
I know it's possible to do %s/[:\|?].*/:
for example to replace everything that comes after :
and ?
with :
我知道可以做%s / [:\ |?]。* /:例如替换之后的所有内容:和?用:
Is it possible to replace everything that comes after :
and ?
with :
and ?
respectively?
I tried %s/[:\|?].*/:\|?
and it doesn't work
是否有可能取代之后的所有内容:和?用:和?分别?我试过%s / [:\ |?]。* /:\ |?它不起作用
1 个解决方案
#1
0
:%s/\d\+.\zs.*//g
Using \zs vim will use everything after digits on substitution see :h \zs
使用\ zs vim将使用替换后的数字后的所有内容:h \ zs
#1
0
:%s/\d\+.\zs.*//g
Using \zs vim will use everything after digits on substitution see :h \zs
使用\ zs vim将使用替换后的数字后的所有内容:h \ zs