一直在寻找这个地方.假设我有一个像这样的XML块:
<leftcol>
<block icon="tips" text="Is it right for you?" url="/support/feasibility.html" link="Feasibility evaluation"/>
<block icon="question" text="Interested?" url="/support/question.html" link="Ask a question"/>
<block icon="docs" text="Want some details?" url="/docs/" link="View documentation"/>
<block icon="box" text="Like It?" url="/purchase.html" link="Purchase online"/>
</leftcol>
Run Code Online (Sandbox Code Playgroud)
我想使用Vim快速跳转到(或删除)属性及其值.这样做有什么好的正则表达式?
我尝试了显而易见/ .*=".*?"但却过于贪婪 - 如果我在同一条线上有两个属性,它会同时选择它们.
任何帮助将非常感激.我特意寻找正则表达式而不是插件.
在vim非贪婪的运算符是\{-}你可以搜索:
/ [a-z]\{-}=
Run Code Online (Sandbox Code Playgroud)
匹配每个属性的LHS.
使用以下非贪婪搜索模式完全搜索/匹配属性,假设"已在属性的RHS上的任何位置使用:
/[a-z]\{-}="[^"]\{-}"
Run Code Online (Sandbox Code Playgroud)
要将光标移动到搜索模式的开头,请使用:
//
Run Code Online (Sandbox Code Playgroud)
要将光标移动到搜索模式的末尾,请使用:
//e
Run Code Online (Sandbox Code Playgroud)
最后删除整个搜索模式使用:
d///e
Run Code Online (Sandbox Code Playgroud)