I don't want to disable recording entirely, but I'm not happy with vim keeping my recordings between sessions, and occasionally I fat finger the @ key and end up with a bunch of garbage in the active buffer.

How do I ensure that all recordings are deleted (e.g. when I restart vim)?

  • 3
    Macros are stored as a register in the viminfo file. AFAIK there is no obvious way to distinguish between a "normal" register and a macro other than overriding the q mapping and storing this information somewhere. Jan 29, 2016 at 16:23
  • I agree with @Carpetsmoker. If you fat finger the @ key, you can always hit u to undo the change.
    – Wildcard
    Jan 29, 2016 at 16:37
  • @Carpetsmoker, what about deleting all registers, then? Jan 29, 2016 at 18:04
  • See vi.stackexchange.com/a/10528/10337
    – laktak
    Dec 6, 2016 at 19:27

1 Answer 1


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 @)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.