I know this is a core vim feature, so forgive me if this is not the right place.
I’ve been using vim and neovim for a few years now and one of the features I use often is the incrementing and decrementing of numbers (
<ctrl>b and the likes). This works for decimal, octal, binary and hexadecimal numbers and you can even increment incrementally with
g<ctrl>a. Through the
nrformats option you can enable or disable incrementing hex, bin or other types of numbers.
But it only supports the most common notation of these numbers, which is most noticeable for the hexadecimal numbers.
For example, pressing
0x10F will change it to
0x110, but only when is has that leading
0x in front of it.
Some languages, such as (System)Verilog or VHDL, use a different format, which means increment and decrement will not work here.
I’ve been looking for a plugin that can reliably offer that experience for other formats, but they always have some form of side-effect:
g<ctrl>a does not work, cursor is moved, registers are overwritten, jumps are inserted etc.
I’ve tried to add support to one plugin (see nextval.vim), but ultimately gave up on it because it was breaking too many other things for me.
So I am wondering what would be the best way for (neo)vim to support uncommon number formats?
Should this be achieved through a plugin or should vim handle this internally?
I don’t think hard-coding multiple formats is a sustainable way.
Perhaps through a more flexible
nrformats option which allows you to specify patterns?
Or could treesitter be used to inform neovim that the word under the cursor is a hexadecimal value and should thus be handled that way?
In short I would like to add support for other number formats to the increment/decrement feature but I have no idea where to start or even what the best way to go would be.
I was hoping someone might be willing to provide some insight how to tackle this the best way.
I was thinking of creating an issue on the neovim github, but I am not sure if that is the right place.