Searching in vi editor
To search for a word in the vi editor follow the below steps:
Step 1: Press Esc if you are in insert mode
Step 2: Press /
Step 3: Type the word or pattern you want to search
Step 4: Press Enter to seach
Step 5: Press ‘n’ to find the next occurence of word/pattern and ‘N’ to go to previous occurence
Example: /is
In the previous command you notice that it searches the pattern within a word also like if I’m searching for ‘is’ then the previous command also include ‘distribution’ because it contains ‘is‘ in it but, if you want to seach whole word follow the below steps:
Step 1: Press Esc if you are in insert mode
Step 2: Press /
Step 3: Type \< to mark the begining of word
Step 4: Type the word you want to seach
Step 5: Type \> to mark the end of word
Step 6: Press Enter to seach the word
Example: /\<is\<
Mastering Search and Replace in Vi Editor
Vi Editor, a powerful text editor renowned for its efficiency and versatility, is a staple tool for Unix/Linux users. Mastering its search and replace functionalities can significantly enhance productivity and streamline text editing tasks. In this comprehensive guide, we will delve into various techniques and strategies to effectively search for and replace text within Vi Editor, empowering users to harness its full potential.
Table of Content
- Understanding VI Editor
- Searching in vi editor
- Replacing in vi editor
- To replace all occurences in file Using Vi Editor
- Replace the word within the given range in Vi Editor
- Ignore case sensitivity in Vi Editor
- How to Search and Replace in Vi Editor – FAQs