According to the manual:
Use of "\V" means that in the pattern after it only the backslash and the terminating character (/ or ?) has a special meaning. "very nomagic"
The phrasing is somewhat misleading. What this actually means is that you always need to escape the backslash (\
-> \\
), but you only need to escape /
and ?
when they are used as terminating characters. Namely:
To search forward you have to start with
/
, so/
becomes a terminating character. Thus you need to escape/
(and\
), but not?
:/\Vhttp:\/\/vimdoc.net\/search?q=\/\\\\
To search backwards you have to start with
?
, so?
becomes a terminating character. Thus you need to escape?
(and\
), but not/
:?\Vhttp://vimdoc.net/search\?q=/\\\\
However, when you do a replace you can avoid the leaning toothpick syndrome almost entirely, by choosing a terminating character that is neither /
nor ?
. Here only \
needs to be escaped:
:s!\Vhttp://vimdoc.net/search?q=/\\\\!...!
You can still minimise your pain even when searching forward. Since you have way more slashes than question marks in your pattern, you start by searching backwards first, just to set the pattern, then change search search direction:
?\Vhttp://vimdoc.net/search\?q=/\\\\
/
n
Another consequence is that you only ever need to escape \
when using \V
patterns with the search()
function:
:echo search('\Vhttp://vimdoc.net/search?q=/\\\\', 'c')