Suppose caret is on the line 10 and I've recorded macros @d.

I need to replay macros until line 25. If I know that macros move caret one line per execution, I can calculate that it should be executed 25 - 10 = 15 times.

So the command will be 15@d.

But is it possible to use something like 'until line':


I think you can use this for specific line

:10,15 norm! @d

If you want something like until line, you can use this instead

:.,15 norm! @d

Or a more visual way, by selecting the lines you want to change via Visual mode and then execute the command

:norm! @d


You can also use 15: from normal mode to execute the macro for the next 15 lines

15: norm! @d

Thanks for @dedowsdi for the tip :D


:h range

:h normal


  • 1
    You can omit norm!, you can also use 15: from normal mode to do it quickly. – dedowsdi Nov 16 '19 at 7:47
  • 2
    @dedowsdi im not aware that you can omit norm! here—macro replay is a normal command... – D. Ben Knoble Nov 16 '19 at 14:38
  • @D.BenKnoble You are right, sorry for the noise. – dedowsdi Nov 16 '19 at 22:47
  • 2
    @dedowsdi Thanks for the 15: tip. Adding it to my answers :D – Rickyson Nov 17 '19 at 7:01

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.