O'Reilly logo

Mastering Vim by Ruslan Osipov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Very magic

Very magic mode treats every character apart from letters, numbers, and underscores as a special character.

You can set very magic mode for a command by prefixing your regex strings with \v (for example, /\vfoo or :s/\vfoo/bar).

Very magic mode is often used when many special characters are to be used. For instance, we used the following example to replace cat hunting mice with mice hunting cat:

:s/\(cat\) hunting \(mice\)/\2 hunting \1

In very magic mode, this can be rewritten as follows:

:s/\v(cat) hunting (mice)/\2 hunting \1

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required