When executing an ex command I can use the variable v:count
to get the count which was given to this command. From :h v:count
, if I create this mapping:
:map _x :<C-U>echo "the count is " . v:count<CR>
And use 12_x I'll get a message
the count is 12
How can I do the same with a macro?
When calling a macro 12 times with 12@a how can I know that the current execution is the nth of the 12?
So far I tried to create a macro which show the count like like:
qaa<C-r>=v:count<CR><Esc>q
But when I play it with 12@a; I simply get 12 zeros:
000000000000
Which makes me think that the variable v:count
is not used by macros.
:h [count]
help gives an insight that repeating a macro is no different than repeating any other command, e.g.3D
.v:count
isn't used in a macro.@
so that it takes a char withgetchar
, and then run the text fromgetreg
v:prevcount
would give you the count for that particular macro, but only for the first run.v:count
is giving you the count for thea
, not the@a
.