Recording a macro in vim involves pressing
q followed by a letter in visual mode. Next time you press the letter it will run the recording. Handy, but not so great when you accidentally store something in
w and then press it when you really meant to save.
The quickest way around this is to press
qwq in visual mode. This just records an empty macro for register
You can see what’s been recorded by running the
:reg command. It’s often possible to work out what it is that you’re accidentally running by looking at the listing.
Macros can be wiped in a more manual way by running
:let @w=''. (Replace
@w with the register that you corrupted).
Various registers are used by vim to implement the likes of yank so it’s dangerous to arbitrarily clear all the macros, however a simple vimscript function could clear all the alphabetical registers which should be safe.