Vim中的非贪婪匹配

折腾了一个HTML文件,想把标签中一些不要的属性去掉,直接的话就直接匹配到行末了,想想vim这么高级的东西应该支持非贪婪匹配吧,于是在google和自带帮助的指引下折腾出来了。其实很简单,在:h non-greedy一条中有说,使用{-}来匹配,和*的功能类似,于是乎就有:

  • 默认贪婪匹配到行末:/<a.*>
  • 使用非贪婪匹配本标签:/<a.\{-}>
This entry was posted in 善用佳软 and tagged , , . Bookmark the permalink.

5 Responses to Vim中的非贪婪匹配

  1. rainy says:

    我懒得注册flicker,那张瀑布那张实在震撼到了我,拍的太好了!!!教教我你是怎么进步这么快的!!!

  2. Pingback: Tweets that mention Vim中的非贪婪匹配 | 湖间小筑 -- Topsy.com

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>