Searching for a String
The forward slash [/] is used to find the next occurence of a string.
The syntax of the search command is:
where you substitute the actual string you wish to search for instead
of the word "string" above.
If you wish to find the previous occurence of a string use the question
mark instead of the forward slash. Notice that "?" and "/" usually
appear on the same key on the keyboard. You can repeat the previous
search without re-entering the command by using the [n] and [N] keys.
The [n] key will repeat the last search exactly as entered and the [N]
key will repeat the last search in the opposite direction.
Special Characters in Search Strings
Several characters take on special meaning when used in search strings.
They allow you to search for strings in specific positions of the file,
or allow you to perform wildcard searches (i.e., look for a match on
any character within a pattern in your search string). These special
characters and their functions are listed in the table at the bottom of
this section.
Here are some examples: When the circumflex is the first character in
the search string "vi" will look for the next line that begins with the
string which follows. For example,
would find the next line that begins with today.
The dollar sign used after a string will find the next line that ends
with that string. For example,
would find the next line that ends with a question mark.
The period [.] is used to match any character, anywhere in a search
string. For example,
would find the words time, tile, and mattress. It would find any word
that contained a "t" followed by any two characters and then an "e".
The characters "\>" are used to search for a word that ends with a
specific string of characters. For example,
would find the next word that ends with "ing".
The characters "\<" will search for a word that begins with with the
string entered. For example,
will find the next word that begins with "9Lives".
Square brackets surrounding two or more characters will match any
single character located between the brackets. For example,
would find the next occurrence of either "disc" or "disk".
Search String Special Characters
Symbol Meaning
----------------------------------------------------------------
^ matches beginning of line
$ matches end of line
. matches any single character
\> matches the end of a word
\< matches the beginning of a word
[] matches any of the characters between the brackets
Click here to go to the next
section.
Or click here to go to the top of
the chapter.