I've been using those more and more recently and have noticed a couple interesting things to be aware of. First, Vim interprets a dash character immediately preceding the number as a negative sign. (In playing around a bit I suspect this behavior is slightly influenced by the syntax rules for the particular filetype you're working with.) The effect of this is to flip the behavior of CTRL-A and CTRL-X. Secondly, if the first digit of the number is '0', Vim will behave as if the number is octal, so incrementing "07" once will result in "010". Similarly, a prefix of "0x" or "0X" will cause a number to be treated as hex.
Re:Vim anti-patterns
by johncoltrane on Tuesday February 07, 2012 @05:22PM
(#3563914)
To avoid the "07" -> "010" problem you can add
set nrformats-=octal
to your .vimrc.You can prepend a count to that too, to increment/decrement by a fixed amount.
This gets scary useful when you use tpope's speeddating plugin.
Increment a number on or after the cursor with Ctrl-A and decrement with Ctrl-X in normal mode. Saves a few keystrokes over having to replace or enter insert mode.