If you have a file that uses the same word over and over again, you might want to find one particular place that the word is used. You can repeat the search with the n command until you find the place you want. That can take time and work, though.
For example, suppose you want to find the word "treasure" in the sentence that has words something like "Los Alamos residents...treasure," but you can't remember exactly how the sentence is written. You could use wildcards in your:
but then the phrases "Los Alamos" and "treasure" have to be on the same line of the file you're searching - and they won't always be. Also, you want your cursor on the word treasure , but that search would put the cursor on Los instead.
"Hmmm," you say, "How about two separate searches, like this?"
/Los Alamos /treasure
The problem there is: the file might have the phrase "Los Alamos" all through it; you might have to type n over and over until you get to the sentence with treasure .
Here's the easy way: a compound search. Say your cursor is on line 1 of the following file:
Before the second World War, there was a treasured boys' school in what was to become the city of Los Alamos, New Mexico. The school at Los Alamos changed the lives and made a lifelong impression on most boys who attended. One of the boys who attended the Los Alamos school went on to propose that remote set of mesas as a site for the U.S. Government's ... Since the war ended, most of the boys' school ranch buildings have been torn down or replaced. But there's one building that Los Alamos residents still use and treasure. It's The Lodge, a log building on the edge of what's now ...
Type the command:
That means "find the first occurrence of
Starting at the top of the example above, that search will skip past all the
words until it finds the word
on the last line shown.
(It's probably smarter to type just
Another example: a C programmer who wants to find the
call just after the line where
is incremented by two (