···11+---
22+title: Incrementing and decrementing
33+---
44+55+# Incrementing and decrementing
66+77+A useful feature that might not be super well knows is the ability to increment and decrement with `C-a` and `C-x`.
88+99+## Basic usage
1010+1111+Use `C-a` to increment and `C-x` to decrement, optionally prefixed by a count.
1212+Note that `vim` will jump to the next thing it can increment/decrement in the line.
1313+1414+Here I increment/decrement the first number,
1515+show that it jumps to the next relevant location in the line,
1616+and finally use a count with `1000<C-a>`.
1717+1818+asciinema(u3IQ2BGQ16Au2KqsRdTA32cVY)
1919+2020+## Usage with a selection
2121+2222+If you make a selection and try to increment/decrement it will do so per line,
2323+taking your selection into account.
2424+So the first valid thing in the line that is inside the selection will be targeted.
2525+2626+asciinema(0bdcvVBYSiYhKT1a9aLgsiSXn)
2727+2828+There is another more obscure feature by prefixing the action with `g`.
2929+This will increment the numbers with an increasing sequence.
3030+I think an example shows it off better than anything else.
3131+3232+Here I create a line "0. item" and duplicate it a few times.
3333+I visually line select everything (`ggVG`) and do `g <c-A>`.
3434+3535+asciinema(PN45fc01eQ2LrOhUBD99Pdx3I)
3636+3737+## Settings that affect usage
3838+By default incrementing/decrementing works not only for decimal numbers but also on binary and hexadecimal numbers.
3939+4040+asciinema(yKsVIo6FtTuTETHNkNRXzXo3R)
4141+4242+The two other modes available is "octal" and "alpha".
4343+The latter one is weird but might occasionally be useful.
4444+Note that it only works on single characters, so "z" won't turn into "aa" on increment.
4545+4646+asciinema(um2yGsUBaxlJ5d52Hx3Am5ET1)