CTRL-{A,X} in Vim
Turns out that CTRL-A and CTRL-X are actually useful.
A little while ago I learned about the CTRL-A and CTRL-X commands in vim. If you are not familiar, CTRL-A is used to increment the first number after the cursor while CTRL-X is used to decrement.
I thought this was neat and filed it away as a fun party trick (yes, I am a blast at parties).
After using it only sparingly since learning, it finally dawned on me where this command could shine… MACROS!
Above you can watch me yank a line, put the line, and then increment the integer. Those three actions are recorded as a macro into register w
. We replay them a number of times to build up a list from 1 to 10.
Of course, if I had just RTFM I would have come across this…
Sigh… Oh well. While we are here, what else can we learn from the docs? Poking around a bit more, I came across this little bit.
And in action…
Awesome. Now go show off your vim-foo!