vim - How do you apply a macro x amount of times per line where x depends on the line -


say have like

a & 1234567890 b & 1234567890 c & 1234567890 d & 1234567890 e & 1234567890 f & 1234567890 

is there way use vim macro such can run macro/command x amount of times per line, x depends on line? in case, run 2wx^ on each line x times, x line number such result becomes

a & 234567890 b & 34567890 c & 4567890 d & 567890 e & 67890 f & 7890 

thanks in advance

if macro recorded in register q, can run:

:exec 'normal ' . line('.') . '@q' 

on line want. macro want cursor kept on 1st column before being run.

you can - better - in different way, if describe what want do. example, perhaps skip macro altogether , use instead:

:exec 'normal ^2w' . line('.') . 'xj' 

if need line offset (e.g. of 1), use:

:let nr = line('.') - 1 | execute 'normal ^2w' . nr . 'xj' 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -