I studied a tutorial for vim syntax files and found this example:
" Floating point like number with E and no decimal point (+,-)
syn match celNumber '[-+]\=\d[[:digit:]]*[eE][\-+]\=\d\+'
I was surprised that it uses both \d
and [:digit:]
. I thought they mean the same thing. The vim help for pattern
says:
Character classes:
magic nomagic matches ~
...
\d \d \d digit: [0-9]
And for [:...:]
character classes:
- A character class expression is evaluated to the set of characters
belonging to that character class. The following character classes
are supported:
Name Func Contents ~
...
[:digit:] [:digit:] decimal digits '0' to '9'
So what is the difference? Can't the example pattern \d[[:digit:]]*
be simplified to \d\+
?