Showing posts with label match. Show all posts
Showing posts with label match. Show all posts

Thursday, May 15, 2008

Start of Match

When searching or writing macros in Vim, it's sometimes helpful to have a search position your cursor at the end of the matching term rather than the beginning. You can use the start of match atom to accomplish this.

/some term\zs

This would match "some term" and position your cursor at the end of the match. See (help :regexp) for other atoms and general regexp goodness.

Thanks to Chris Sutter for contributing this tip.

Wednesday, March 5, 2008

Delete Lines Matching Keyword

Neat little trick using the global ex command to remove all lines matching a given pattern.

:g/.*foo.*/d

Of course you can use any ex command at the end and you can put in whatever pattern you'd like.