but it kept going to the same spot as before.  I will not change the [#].
Where is the match for (?  I can't figure it out.

Using a simple change to Tim Chase' original substitution response, you have:

:'<,'>s/\d\+/\=line('.')-line("'<")

which replaces the *first number* on every line in the visual
selection. look at the difference between the two to see that the
responses have all used opIndex as a marker to know what number is to
be operated on.

this modification doesn't really allow for any fine degree of control
(like selecting which number on a given line to increment), but it
works for the examples you've given.

if you don't want to type it in every time,
:vmap <C-I> :s/\d\+/\=line('.')-line("'<")<CR>
which adds ctrl-i as a key in visual mode to do the job.

the ex (colon) commands are one of the major parts of vim - I would
highly recommend learning them a bit more, if you want to get the most
out of the program. For me, without ex there would be very little
point in using vim at all - I couldn't even write to a file ;)

Cheers.

Reply via email to