How to find and replace text using vi or vim
Both vi and vim text editor comes with substitute command for finding and replacing text.
The syntax is as follows:
The substitute command can be used as per your requirements.
Task: VI / Vim Basic Find and Replace
To find each occurrence of ‘UNIX’, and replace it with ‘Linux’, enter (press ESC, type : and following command):
Task: Find and Replace with Confirmation
Find a word called ‘UNIX’ and replace with ‘Linux’, but ask for confirmation first, enter:
Task: Find and Replace Whole Word Only
Find whole words exactly matching ‘UNIX’ to ‘Linux’; and ask for confirmation too: