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

Similar Reads

Understanding VI Editor

Before delving into search and replace operations, it’s crucial to understand the basics of Vi Editor. Developed by Bill Joy in 1976, Vi Editor offers two primary modes: insert mode for inserting text and command mode for executing commands. Familiarity with these modes is essential for efficient navigation and editing within Vi....

Searching in vi editor

To search for a word in the vi editor follow the below steps:...

Replacing in vi editor

To find and replace word in vi editor we use :substitute or :s command syntax of the command is as follows:...

To replace all occurences in file Using Vi Editor

To replace all occurences in the file we will use wildcard charcater ‘%’ , just add ‘%’ character before the command to use it,...

Replace the word within the given range in Vi Editor

In the syntax of :s command described earlier in this article we have seen how to add range in the command to replace words only in a given range...

Ignore case sensitivity in Vi Editor

To ignore the case sensitivity of the pattern/word use ‘i’ flag, you can use the flag with any of the command described above....

How to Search and Replace in Vi Editor – FAQs

How do I search for a specific word in Vi Editor?...

Conclusion

In this article we discussed how to find and change text in Vi Editor which a popular tool in Linux. We started by understanding what Linux and Vi Editor are. Then, we explored how to search for words or phrases in Vi Editor and replace them with new ones. We also looked at some useful tricks like searching for whole words and making case-sensitive changes. Additionally, we covered common questions like how to undo changes. By following these tips, you can become more efficient at editing text in Vi Editor....

Contact Us