To search up from the current cursor position, run the following command:/patternEnter, where pattern indicates the specific character sequence to search. To search down from the current cursor position, run the following command :? Run the following command to search for patternEnter from the current cursor position by pressing Enter & nb:
/Pattern Enter
Where, pattern indicates the specific character sequence to be searched.
To search down from the current cursor position, run the following command:
? Pattern Enter
After pressing Enter, vi searches for the specified pattern and positions the cursor at the first character of pattern. For example, to search for the word "place", type:
/Place Enter
If vi finds the place, it positions the cursor at p. To search for other matches of place, press n or N:
N, continue to search for place in the same direction.
N. search in the opposite direction.
If vi does not find the specified pattern, the cursor position remains unchanged and the following message is displayed at the bottom of the screen:
Pattern: not found
4.5.1 search for special matches
In the preceding example, vi finds any sequence containing place, including displace, placement, and replaced.
To find a single place, type the word and add a space before and after it:
/Place Enter
To find the place that appears only at the beginning of the row, add a hyphen (^) before the word ):
/^ Place Enter
To find the place that appears only at the end of the row, add a currency symbol ($) after the word ):
/Place $ Enter
Use ^
To search for a character with a hyphen (^) or a currency sign ($), add a backslash (\) before the character (\). Use the backslash command vi to search for special characters.
Use $
Special characters refer to characters with special functions in vi (such as ^, $, *,/, and .). For example, $ usually indicates "going to the end of a line", but if $ followed by a \, $ is just a common character.
Use \
For example,/(No \ $ money) searches for the character sequence (No $ money) up ). Follow the escape character (\) command vi before $ to search for currency symbols by word.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service