Resource | A quick replace in Vim

A quick replace in Vim

Sometimes you just don’t want to type what you are trying to replace. In Vim, if you have set incsearch set in your .vimrc you can use ctrl-lto autocomplete the next character of your search.

Combine this with another feature, where if you do a substitution with a blank regular expression, Vim will use your last search term. What does this look like? Well, a fast and effortless replacement:

To recap:

  1. Set incremental search in your ~/.vimrc by adding set incsearch.

  2. Search for the term you want to replace with / using ctrl-l to complete the full match.

  3. Use a blank substitution to replace items matching the last search :s//new_text/g (the g will replace all occurrences found on that line).

Happy Vimming!

Message sent
Message could not be sent
|