Clear Annoying Vim Macros

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 w.

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.

Clear Annoying Vim Macros

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s