quarta-feira, janeiro 30, 2008

Looking for many words at once

I use Vim daily and my admiration for it always is renewed. It has so may features that I doubt any one can use 100% of its capacity.

One of the Vim's features I like too much is its ability to search different words at once in text.

When we want to find a word we enter in command mode and we type:

/word <ENTER>

- But what if we want to find two or more words ? Do we need to do separate searches?

No! We do just one search in command mode with each word separated by escaped pipes (\|) :

/word1\|word2\|word3 <ENTER>

Figure 1 shows a search for four words. Notice that spaces are considered as part of the word we are looking for.


Figure 2 shows the result of the search.


I hope this tip will be as useful for you as it is for me.