How can I repeat the last VIM macro?
Asked Answered
S

2

63

I know how to repeat the last command in Vim. I use ..

But how can I repeat the last macro? It's a little non-comfortable to press @q everytime I want to repeat it.

I tried with . but it just repeats the last command from the macro.

Is there a shorter way of doing that?

Sciolism answered 26/12, 2013 at 13:44 Comment(3)
Read :h 10.1 for a short, practical introduction to macros. It has all the answers.Willmert
@Willmert Thanks! Useful information.Ruttish
It may be helpful to know that it is possible to do 3@q if you would simply chain the macros - i.e. if you would otherwise type @q@q@q.Discriminatory
E
91

Yes, you can use @@ to replay the last used macro.

As a bonus, use @: to replay the last ex command. (And then that becomes the "last used macro" that can be repeated with @@.)

Evonneevonymus answered 26/12, 2013 at 13:46 Comment(1)
awesome :D :D :D :DGunnysack
H
10

I find @@ a bit hard to type and as I don't use , much - and it's close enough to .:

:map , @@
Hakan answered 16/11, 2017 at 14:53 Comment(1)
genius! That helps a lotUnseat

© 2022 - 2024 — McMap. All rights reserved.