RSS Amplifier

slama.dev · Mar 21, 2020

Incrementing and Decrementing Numbers

0
Sign in to vote or save

Tomáš Sláma · slama.dev

21. 3. 2020 · Vim 1/2 · 1 min read · [edit]

Some of you might know that pressing <C-a>/<C-x> in normal mode increases/decreases the next number on the line the cursor is currently on:

1
There are 12 apples. -<C-a>-> There are 13 apples.

But did you also know that it can handle other bases and even alphabetical characters (worked for me but might need to be configured – see this wiki article):

1
2
3
There are 0b1100 apples. -<C-a>-> There are 0b1101 apples.
There are 0xc apples. -<C-x>-> There are 0xb apples.
This is 'a'. -<C-a>-> This is 'b'.

Equipped with this knowledge, one can easily add to and subtract from any number (10<C-a>), create a list of numbers in a given base (a relatively simple macro), play around with Caesar ciphers and generally do many things that would likely not be possible in other text editors.

Read the original on slama.dev

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.