The contents of register w
are xx
. When I try to run the following command:
:for i in range(1,10) | if i > 5 | @w | endif | endfor
It throws an error saying that E492: Not an editor command xx
.
How do I execute the macro?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityUse :h execute
combined with :h normal
, like so:
:for i in range(1,10) | if i > 5 | exe "normal @w" | endif | endfor
Short explanation: execute
/exe
runs it's argument as an Ex
command and normal
behaves as you would press given symbols/keys yourself.