[wellylug] vi(m) question.
grant at mclean.net.nz
Sun May 9 08:22:26 NZST 2004
> I'm still confused (sorry!) about the "\+\" bit.
> Starting from the left most delimter you first have a "^" which says
> "start of string". Then you escape the "(", followed by a space,
> followed by an escaped "+" which means one or more spaces required at
> the start of the string. Then you escape the ")" and then the second
The only bug in your thinking is the use of the word "escape".
Usually we escape things so that they do not have special meaning.
For example to create a file with a dollar sign in the name, we
would use a backslash in Bash:
But in Vim (for reasons I've never quite understood), we use the
backslash to make characters special rather than not special.
For example, to search for a plus sign you would simply use the
pattern '+'. But to use the plus sign in its regex meaning of
'one or more occurences of the previous thing' we need to make it
special by putting a \ in front of it.
Just to keep things interesting, Vim recognises the most common
regex characters as special without requiring a backslash:
^ . * $
Pretty much any other character without a backslash prefix will
only match the literal character.
More information about the wellylug