How do I make Ctrl-A increment 007 as decimal instead of octal?
Answer
:set nrformats-=octal\<CR>
Explanation
If you work with IDs, ticket numbers, or zero-padded counters, Vim's default octal behavior can be surprising. With octal present in nrformats, <C-a> interprets numbers that start with 0 as base-8, so incrementing 007 may behave differently than expected in decimal workflows. Removing octal from nrformats makes <C-a> and <C-x> treat those values as decimal instead.
How it works
:set nrformats-=octal
nrformatscontrols how Vim recognizes numbers for increment/decrement-=octalremoves octal interpretation from the option- After this,
007is treated as decimal seven for numeric operations
Example
Before changing the option:
build_007
With cursor on 007, <C-a> can follow octal rules.
After running :set nrformats-=octal, <C-a> increments as decimal (008, then 009, then 010) in the same token.
Tips
- Add this to your config if your codebase uses leading-zero decimals frequently
- Check your current value with
:set nrformats? - You can keep other formats (like
hex) while disabling only octal