Each row is:

Or(a=a[0], b=b[0], out=out[0]);
Or(a=a[0], b=b[0], out=out[0]);
Or(a=a[0], b=b[0], out=out[0]);

and I need:

Or(a=a[0], b=b[0], out=out[0]);
Or(a=a[1], b=b[1], out=out[1]);
Or(a=a[2], b=b[2], out=out[2]);

I tried this solution as:

:let t=[]  # then ctrl-v

But this increments each subsequent number, not per row. I couldn't find/understand other solutions.

Thank you!


Do you mind some Awk?

:%!awk 'gsub(/[0-9]+/,i+0){i++}1'

This means:

  • gsub(/[0-9]+/,i+0) If there is any number in the line, substitute it by i+0.
  • {i++} If a substitution occurred in this line, increment i.
  • 1 is a short for "print the resulting line".

In case you are wondering, i+0 forces the conversion of i to integer in the case i is unset (case which happens in the first line).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.