Search and replace all instances of a string in Vim

Written on December 8, 2017

Being able to search and replace all instances of a string in a text editor definitely speeds up the editing process. In an editor like Atom, the process is mapped to a keyboard shortcut but I find myself still reaching for the mouse to kick off the Find all and then Replace all process.

With Vim, it’ll take some time to remember the command for search and replace, but I think the implementation is clever and I really dig how to process can all be done without reaching for the keyboard.

Search and replace animation gif

You can even get Vim to provide a confirmation prompt for each instance found and asks whether you want to actually replace it.

Stay in touch

Thanks for reading this article. I'd love to stay in touch and share more tips on programming and side projects with you. Sign up and I'll send you my articles straight to your email, you'll also get a free copy of the light themed version of my Git cheat sheet.
Git cheat sheet preview image