I have a file like the following : two different files were yanked one after another, and the numbers subsequently don't match anymore.
... 46
atom 142 option 47
atom 143 option 48
atom 12 option 7 # There's a discontinuity in the numbers at this line
atom 13 option 8
atom 14 option 9
atom ...
I would like to take the columns of numbers using visual-selection, and add the missing constant (in my example, for the first column, adding 132 to the last three lines would be perfect).
I don't know if regexp allow mathematical operations (otherwise I could try a macro using Ctrl-X / Ctrl-A, but it won't use visual selection anymore and I'd like to keep it).
(The expected result would be something like:)
... 46
atom 142 option 47
atom 143 option 48
atom 144 option 7 # Discontinuity in the first numbers column is gone !
atom 145 option 8
atom 146 option 9
atom ...
<c-a>
/<c-x>
in visual mode. See:h v_CTRL-A
– Peter Rincker Jun 15 '16 at 16:07vim --version
I only have Vim 7.2, and I cant update that (I do not have admin rights). – Feffe Jun 15 '16 at 16:11:II
. The harder way: if the first bad number is on line 73, do something like this::73,$s/\d\+/\=submatch(0)+132/
, then fix the align. – Sato Katsura Jun 15 '16 at 16:52