0

次のようなものがあるとしましょう

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

マクロ/コマンドを1行あたりx回実行できるようなvimマクロを使用する方法はありますか?xは行に依存しますか? この場合、2wx^各行を x 回実行します。x は、結果が次のようになる行番号です。

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

前もって感謝します

4

1 に答える 1

0

If your macro is recorded in register q, then you can run:

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

on any line you want. Your macro will want the cursor kept on 1st column before being run.

You can also probably do it - better - in a different way, if you describe what you want to do. For example, perhaps you could skip the macro altogether and use something like this instead:

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

If you need a line offset (e.g. of 1), you could use:

:let nr = line('.') - 1 | execute 'normal ^2w' . nr . 'xj'
于 2015-07-21T23:00:11.363 に答える