How do I search for a whole word only, excluding partial matches?
Answer
/\<word\>
Explanation
The \< and \> atoms create word boundaries in a search pattern, matching only complete words and not substrings within larger words.
How it works
\<matches the start of a word\>matches the end of a word/\<the\>matchesthebut notthereorother
Example
the theory of the other theme
Searching /\<the\> matches only the two standalone the words, not theory, other, or theme.
Tips
*and#automatically add word boundaries- Boundaries work in
:substitutetoo::%s/\<old\>/new/g \<matches at a transition from non-word to word character- Word characters are letters, digits, and underscores