vim ungreedy patternt match

Use .{-} instead of greedy .*. Selects 0 or more, but as few as possible. Example, separate one liners in html:

%s/(<[a-z]+.{-})(<[a-z]+)/1r2/g 

Leave a Reply

Your email address will not be published. Required fields are marked *

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=""> <s> <strike> <strong>