Peter Palm wrote:
Op woensdag 11 oktober 2006 11:46, schreef Marius Roets:
Hi everybody,

I'm using Vim 7.0.94 on Linux. I use C-A and C-X from time to time to
increment/decrement numbers. However when there is a leading zero I
get very strange behaviour with both.
Example:
01
02
03
04
05
06
07
08
09
10
11

:nmap <F7> <C-X>j

I position the cursor on 01 and press F7, this works fine up to 08.
For 08, 09 and 10, the leading zero dissapears.

 :nmap <F7> <C-A>j

Use the same unmodified list.
This is even weirder. 07 becomes 010, 08 becomes 9, and the rest
seems ok.

That's because vim knows about octal numbers (base 8 instead of 10). Octal numbers normally start with a 0.

Do others see the same behaviour. What am I missing?

No I don't, I don't like this behaviour as well, so I've put the following in my .vimrc:

set nrformats-=octal


Peter


I've gone even farther: since I want Ctrl-A and Ctrl-X to skip letters (be they A-F or G-Z) and to act on numbers in decimal mode only, I use

        :set nrformats=

(decimal number format is always recognised). This way, repeated use of Ctrl-A will step 06, 07, 08, 09, 10, 11 etc., and Ctrl-X will step 11, 10, 9, 8, 7 etc. or 011, 010, 009, 008, 007 etc. Of course (and this is what I want, but it may or may not be what the OP wants) hitting Ctrl-A or Ctrl-X on the zero of 0x4A now produces 1x4A or -1x4A respectively.


Best regards,
Tony.

Reply via email to