How do you increase a number *directly* under the cursor?
In this case, I usually type r and then the digit I want.
<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
.
As I guess 3[9]42 shall become 4042 (otherwise, Xavier's solution is almost perfect (*)), I'd use the following:
s/\d*\%#\d/\=(submatch(0)+1)
Which could be mapped into:
nnoremap <silent> µ :<c-u>s/\d*\%#\d/\=(submatch(0)+v:count1)<cr>``
in order to accept a count. The only catch I see is that it cannot support repeat (as in :h .
)
(*) In the sense that repeating the command won't help us to increment a series of different numbers by the same amount.