:best of Vim

Showcasing the top Vim plugins, tips and tricks.

What is Vim?

Vim is a text editor for programmers, power users & command-line junkies.

What is :best of Vim?

:best of Vim showcases the best plugins, extensions & tips for making the most of Vim.

It was built for NoVIMber 2011.

Learn more...

Follow

Search & Replace Escaping

Imagine you're editing a line like this:

String path = "/usr/local/share/dir/file.txt";

..and you want to change it to /opt/alt/share....

You could type in something like:

:s/\/usr\/local\//\/opt\/alt\//

And then lose your mind in a sea of backslashes. You don't need to. / is the default pattern separator for search & replace, but you can use almost anything. The first character after :s is taken as the separator, so this much-simpler version works just as well:

:s!/usr/local/!/opt/alt/!

The next time you find yourself counting backslashes to fix a E486: Pattern not found error, remember you have an easy alternative.

Comments...