Tuesday, February 21, 2012

What I learnt playing "vimgolf: replacing each line of a block selection"

The substitute command can use delimiters other than /.

For example, let's say you want to replace the path a/b/c with d/e in the current line.

You could use the usual / as the delimiter and escape the forward slashes in the pattern and replacement like this:
:s/a\/b\/c/d\/e/

But it would be much easier to another delimiter, say ; and avoid the escaping like this:
:s;a/b/c;d/e;

See :help E146 for more detail