Reputation: 6101
I'd like to be able to search
/the\b
to find "the" but not "then".
I also tried searching with very magic turned on:
/\vthe\b
Upvotes: 194
Views: 42061
Reputation: 9420
/the\>
I assume "regexp" means PCRE. It is worth noting that Vim's regex syntax differs from (and apparently predates) PCRE.
See also:
Upvotes: 212
Reputation: 13432
Use \<
and \>
for word start and word end, respectively.
E.g. In your specific case you would use:
/the\>/
Upvotes: 109
Reputation: 772
If very magic
is turned on, then you shouldn't escape the >
character. See what's magic search.
SO in your case you'd do:
/\v<the>
it would search for only the word 'the'.
Upvotes: 47
Reputation: 5716
if you are trying to search a word at your cursor. you can just hit *, or # for backward search.
Upvotes: 18