The aim of this series of blog posts is to shed light on some of the darker corners of the vim text editor that I have encountered over the years. Each post will focus on one particular feature, and should take no longer than a couple of minutes to read.
Today, I’d like to talk about the <C-a>
key sequence (that is,
control+a). It is extremely simple: pressing <C-a>
searches the
current line (starting at the cursor position) for a number, then
increments it.
For example:
<C-a>
where ^
marks the cursor position.
Its inverse is <C-x>
, which decrements the number.
We can also specify a count, for example 20<C-x>
will result in:
Hexadecimal and binary numbers are supported too.
For example, to convert 192
to hex, we can do
192<C-a>