A while ago I wrote a plugin called “kakoune-inc-dec” which allows Vim-style <c-a>
and <c-x>
to increment or decrement numbers inside the selection. Honestly, I thought I’d already announced it here somewhere, but apparently not.
I’ve recently updated it with the following changes:
- switched from
bc
to using shell arithmetic, making the plugin more portable- this also means that signed hex and octal numbers are no longer supported, but I don’t think that’s a big loss
- dropped support for zero-prefixed octal numbers, now only the
0o
prefix is supported, which allowed… - added support for zero-padded numbers; If you increment “001” you’ll get “002” which is probably what you wanted
- added online documentation viewable with
:doc inc-dec
- in particular,
:doc inc-dec number-syntaxes
talks about the trade-offs of supporting zero-padded decimal versus old-style octal
- in particular,
- Not necessarily relevant to end-users, but a while ago Kakoune changed the way it updated the selection after piping content to an external process; the new version takes advantage of the new behaviour and makes it much simpler
I think the only place to go from here would be to move a bunch of logic into a helper script written in, say, Python (since it supports arbitrary-precision arithmetic and sophisticated logic), but that would be an order of magnitude more complexity.