Increment zero-padded decimal
digitalillusions opened this issue · 3 comments
First of all, thanks for the great plugin! I'm using codemirror through the Joplin note taking application, which also includes the ability to enable this vim plugin.
What I've noticed, is that the <Ctrl+a> operator does not seem to like my zero-padded numbers very much, and skips from "07", directly to "010". I dug a little into the source code and found that here
https://github.com/replit/codemirror-vim/blob/master/src/vim.js#L3280 ,
zero-padded numbers are assumed to be octal numbers. I'm not familiar with this notation convention as to me it seems almost more common to encounter 0 padded decimals than to assume an octal number. For the other cases in the list 0b
and 0x
the handling is obviously less ambiguous.
Just wanted to share my thoughts on this issue. I completely understand if the behavior is intentional, but (based on my very limited experience) I believe a large number of people would find handling 0 padded numbers as decimals to be more intuitive than handling them as octals.
EDIT: After further research, I've found that this is absolutely in line with the way vim
handles this operation by default. However, vim
allows the user to disable this by set nrformats-=octal
. Is there maybe a way to add such a setting to this plugin?
Hi,
Zero padded numbers denotes octal in C and JS (and yes it's a dumb legacy feature), so I don't see this changing, as JS is probably the number one target of codemirror.
Just passing by though, I am not a contributor of the project.
It seems we do this on purpose here. My local vim itself does not do it by default. Is this the meant behaviour? Should there perhaps be an option to disable it? @nightwing
This is indeed controlled by the option nrformats in vim, and we should add it. I'll make a pr this weekend.