Thanks to @statox's suggestion, you can solve your issue with:
Firstly, Vim does not increment decimal number, it will try to increment
009500 separately. So the question is why incrementing
009500 removes the leading
As suggested by @sp asic, I think vim is treating this number as an octal number.
Looking at the source code of Vim, a conversion between the string and the actual number is done, using the
You can see the definition of numbers in
Decimal, Hexadecimal (starting with 0x or 0X), or Octal (starting with 0).
009500 is a number starting with a
0, but containing a
9, it's not an octal number, and should not have a leading
You can see the same result calling the
str2nr() function yourself:
00100 is a valid octal number, incrementing it will just add
1 to the result.
00900 is an invalid decimal number, incrementing it will fix it (removing the leading
0) and incrementing it.
Note: This is what I've understood of the little dig I've done in the Vim code, as I didn't understood everything I've read I may be wrong.
I believe the code responsible for the decimal conversion is the following (source):
un = 10 * un + (uvarnumber_T)(*ptr - '0');
if (n++ == maxlen)
Considering the result is
un, you can see that the first
0 won't add any value to the decimal number.