Reputation: 6305
Is it possible to search within vim
for more than one word?
For example:
Let's say i'm inside vim
and I press /
in order to start a search for a certain word, is it possible to search for more than one word in the same search?
Upvotes: 2
Views: 156
Reputation: 172520
If you do this often, my SearchAlternatives plugin may be useful to you.
The plugin provides mappings and commands to add and subtract alternative
branches to the current search pattern. Currently searching for "foo", but
also want to find matches for "bar"? You could type /foo\|bar<CR>
or
/<C-R>/\|bar<CR>
, but once you want to limit the search to whole \<words\>
(like the *
command), and juggle several alternatives, adding and
dropping them as you search, this plugin is quicker than manually editing the
search command-line (which you can still do).
Upvotes: 1
Reputation: 196476
Yes, you can have several branches in a search pattern:
/foo\|bar
See :help \|
.
Upvotes: 4