Search and replace all instances of a string in Vim

Written by Michael Lee 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.

Thanks for taking the time to read this article. I'd love to stay in touch and share more tips on programming and design, side projects and working remotely. Sign up and I'll send you my articles straight to your email.

:wave: Hey hey, I'm Michael Lee! I really appreciate you taking the time to read this article.

Be sure to check out my other articles.