How to fill a register without entering in insert mode?

123 Views Asked by At

I'd like to optimize the initialization of a register when I use it in a macro.

I usually initialize my register by doing something like q:i0 <Esc> "eyiw:q, but I think there is a better way... I'd like to avoid entering insert mode if possible.

1

There are 1 best solutions below

0
Ingo Karkat On BEST ANSWER

qaq (start and immediately stop recording) clears register a.

So, to clear register q and start recording (e.g. a recursive macro), use qqqqq...


From the command-line, you can also do:

:let @a = ''

or

:call setreg('a', '')