As @carpetsmoker mentioned, recorded macros are stored in registers.
Non-empty registers are saved to your viminfo file when you exit Vim. According to :help 'viminfo'
, the default for all OSes when not running in vi mode is to store up to 50 lines of text for each register (the <50
bit). You might also see it as "50
in your setting (they both mean the same thing).
So, to not save registers on Vim exit (with the result of having all empty registers on Vim start) is to change your viminfo
setting. You can put something like the following in your .vimrc (a modification of the
others' default value):
set viminfo='100,<0,s10,h
You can check the current value of your viminfo setting live by running
:set viminfo?
and use that as your starting point for getting rid of the registers.
NOTE: this will also lose any register contents gotten via yank, delete, etc. operations.
NOTE: There is no need to clean up the old content of the viminfo file; the moment you exit Vim, it will save a new file that won't have the contents you specify it to not have (i.e. it will erase existing saved registers when you exit).
NOTE: If you do populate a register via a yank, delete, etc. operation and then fat-finger the @
, you can still end up with a bunch of garbage on the screen, since @
just runs whatever is in a register no matter how it got there (which is convenient for creating macros sometimes, but inconvenient if you accidentally hit @
)
viminfo
file. AFAIK there is no obvious way to distinguish between a "normal" register and a macro other than overriding theq
mapping and storing this information somewhere.@
key, you can always hitu
to undo the change.