Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you increase a number *directly* under the cursor?

In vim et al, you can increase or decrease the number your cursor is on by using CTRLA and CTRLX. However, this increases the whole number but I would like to simply increase the number directly under the cursor. It's a little hard to describe so here's what I mean:

Ctrl+A usage, cursor is over the "6":
[6]5 -> 66

What I need:
[6]5 -> 75

or:
3[8]90 -> 3990

I hope that makes sense.

I've googled a bit but I'm not sure if such a shortcut exists so any tips are much appreciated!

like image 877
Durand Avatar asked May 10 '12 12:05

Durand


2 Answers

<C-a> and <C-x> work on whole numbers (1 or more digits) but not on "parts" of a number. However it takes a "count" so 10<C-a> turns [6]5 into 75.

Another option, since you only want to change one digit, would be to do r7 to turn [6]5 into 75.

like image 67
romainl Avatar answered Nov 14 '22 13:11

romainl


In this case, I usually type r and then the digit I want.

like image 39
Xavier T. Avatar answered Nov 14 '22 13:11

Xavier T.