09 Find and Replace Text in vim Editor | How to Replace Text in Vi Editor | Use Sed Command in vim

How to find and replace text in vi editor, find and replace in vim, find and replace word in vim, find and replace text in vim text editor
Find and Replace in Vim Editor

We can easily find and replace match word in vim text editor, it is very useful if we have multiple same value and we want to change/replace with other value, below are the steps 
Open a file which you want to find and replace the text 

vi /tmp/lokesh

find and replace text in vim editor, find and replace word in vi editor
1 -  We switch command mode by pressing the Esc and Colon ( : )

2 -  We will type %s for search string and then type /lokesh , means we are find lokesh word in the file,  then we will type word which we want to replace like /administrator 

3 -  /g, while the g stands for global, which means that all matching occurrences in the line would be replaced.

To find and replace in vi editor with confirmation

We used only  c for the confirmation, means it will ask you for every match word to replace, we will provide confirmation by pressing Y for yes or N for skip the replace. below screenshot 

vim find and replace with confirmation

Thanks you !! 

I hope this topic gave you all the information you needed. If you have any further questions or would like more detailed directions feel free to contact us using any of the following sources.We look forward to talking to you.

No comments

Powered by Blogger.