• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (deprecated)
You are here: Home / Solution / Vim Increment Number With Dash

Vim Increment Number With Dash

Last updated on November 4, 2025 by Sal Ferrarello

In Neovim, I’m a big fan of CTRL-a to increment a number (and CTRL-x to decrement a number), however when I have dash before the number (e.g. “sprint-23”), this is interpreted as a negative number so incrementing the value
goes to 22 (because -22 is one greater than -23). We can fix this.

The short answer is to add this to your Neovim configuration

 vim.opt.nrformats:append('blank')

or if you’re using Vim

set nrformats+=blank

Neovim has a number of algorithms for identifying numbers to increment/decrement and they are controlled by nrformats (see :help nrformats).

By adding blank to the nrformats, Neovim will

treat numbers as signed or unsigned based on
preceding whitespace.  If a number with a leading dash has its
dash immediately preceded by a non-whitespace character (i.e.,
not a tab or a " "), the negative sign won't be considered as
part of the number.  For example:
    Using CTRL-A on "14" in "Carbon-14" results in "Carbon-15"
    (without "blank" it would become "Carbon-13").
    Using CTRL-X on "8" in "Carbon -8" results in "Carbon -9"
    (because -8 is preceded by whitespace.  If "unsigned" was
    set, it would result in "Carbon -7").

How to Add blank to nrformats

We can add blank to nformats by running this command

:set nrformats+=blank

or we can update our Neovim configuration in our init.lua file with

vim.opt.nrformats:append('blank')

Vim Compatibility

Vim also supports blank as an nrformats value and it looks like this was originally an issue and improvement made in Vim that was ported over to Neovim.

See https://github.com/vim/vim/issues/15033

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP and JavaScript developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a principal engineer.

Filed Under: Computing, Solution Tagged With: neovim, vim

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2026 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in