Tag Archives: tips

Vim whole word search

In perl regexp syntax, \b (b means bareword) can be used for searching a whole word. I.e. \btext\b:

Will match: text, @text, <space here>text!, etc

Won't match: textile, mytext.

I've been looking for a similar feature in vim for months, with no luck, until today. I've found out how to do that, the syntax is simply  \<text\>. Works for search mode (/,?), substitute (:s), and probably for other modes as well.

Actually that's what the #, * keys do (search for the under-the-cursor whole word), and that's how I found that out.

Goodie.