vi Search

You can also search for text strings while in the command mode. Just press the / key, type the string that you're searching for, and hit "Enter". To search forward for the next occurrence of the string, press n. To search backward for the next occurrence, press Shift-N.

Lesson 3 | Lesson 5


You can also perform "fuzzy" searches. If you want to hunt for all instances of a certain word at the beginning of a line, use the ^ character, like so, to find the word "Some":
/^Some

To find all instances of a word at the end of a line, use the $ character. Here's how you'd find "end" at the end of all lines:

/end$

Some characters have special meanings if you insert them into a command. So, to find those characters in a text document, you'll have to tell the system that you're hunting for that character instead of using it as part of a command. To do that, place a \ in front of the character that you're searching for. Here, you're searching for all instances of the string "kernel."

/kernel\.

 

 


Copyright CyberMontana Inc. and BeginLinux.com
All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874