Vim Find Words

From Regex Regular Expression Encyclopedia

Jump to: navigation, search

You can use this recipe for finding single words in a block of text. The expression will find only complete words surrounded by spaces.

[edit] Code

/\<word\>

[edit] How It Works

The word boundary character class \b found in Perl-Compatible Regular Expressions (PCREs) doesn't exist in extended POSIX expressions. Instead, you can use the character class \< to refer to the left word boundary and the character class \> to refer to the word boundary at the end of the word.

Regular Expression Description
\< a word boundary (a space or beginning of a line, or punctuation) . . .
w a w followed by . . .
o an o, followed by . . .
r an r, then . . .
d a d, and finally . . .
\> a word boundary at the end of the word . . .
Personal tools