Picture of Michael Lee
:wave: Hey hey, I'm Michael Lee and this is my site about being a developer, being a dad and making side projects.

Search and replace all instances of a string in Vim with a confirmation prompt

Written on December 8, 2017

Vim’s search and replace command is really nice for quickly searching and replacing all instances of a string. But sometimes you need to be a little careful with the replacement process and might need to review the matched string before you replace it.

Thankfully, simply adding a c to the end of the search and replace all command in Vim will provide a confirmation prompt, allowing you to review before replacing. It also gives you the option to skip over an instance or stop the search and replace process altogether.

Search and replace with confirmation animation gif

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