In Neovim, C-a and C-x increment or decrement a number under the cursor in Normal mode

hungariantoast
2026-02-20T22:14:07Z

Also works in Vim.

Thought this was neat. Wanted to share.

https://neovim.io/doc/user/change.html#CTRL-A
https://neovim.io/doc/user/change.html#CTRL-X

Thanks @spicyq. It turns out Emacs does have this feature built-in (via Org-mode) with the commands org-increase-number-at-point and org-decrease-number-at-point.

The commands:

Work in any mode, not just org-mode

Support prefix arguments with C-u

Do not have a default keybind

I bound the commands to C-z <up> and C-z <down>, since I had previously unbound suspend-frame from C-z:

(keymap-global-unset "C-z" 'remove) ; suspend-frame

Keep in mind you can repeat your last executed command with C-x z (and then just keep pressing z to repeat the command however many times you want).

Of course, now that I've got this far, I'm realizing that typing out either C-u 10 C-z <up> or C-z <up> C-x z + z * 9 is probably a lot more keystrokes than just changing the number myself. (At least for a single number at a single point in the buffer.)

I don't think there is a built-in Emacs feature that does the same thing. You can find several custom Emacs Lisp solutions by searching online though.

Comments URL: https://tildes.net/~comp/1qcf/in_neovim_c_a_and_c_x_increment_or_decrement_a_number_under_the_cursor_in_normal_mode

Votes: 21

Comments: 9