find and replace a String in vi editor on linux? find and replace a String in vi editor on linux? unix unix

find and replace a String in vi editor on linux?


I'd guess the reason you're getting that error message is because you intend to replace the string on all lines, not just the current one. In order to search all lines, add a % to your command:

:%s/totel_email_count/total_email_count/g


To find and replace with vi editor type following:-

Type : (colon) followed by %s/foo/bar/ and hit [Enter] key.

:%s/foo/bar/

for example:-

:%s/old_string/new_string/