I use in my vimrc the following option:

set viminfo+=%

This allows vim to open the last edited files if you don't pass any arguments to vim.

Is there a way to ignore some files? I want to disable the opening of files like COMMIT_EDITMSG, for example.

1 Answer 1


:help viminfo-% gives you some hints on how to achieve this:

Quickfix ('buftype'), unlisted ('buflisted'), unnamed and buffers on removable media (|viminfo-r|) are not saved.

I would simply make those files unlisted; as Vim is invoked from the version control system for the commit message, and usually no other files are edited within that session, the buffer listing (:ls) and naviation (:bnext) isn't particularly important there, anyway.

For COMMIT_EDITMSG, you can hook into the existing filetype detection:

autocmd FileType gitcommit setlocal nobuflisted

or set up your own pattern(s):

autocmd BufNewFile,BufRead COMMIT_EDITMSG setlocal nobuflisted
  • Thanks, it's just what I wanted. If I need to ignore differents files, I need to add one line per file? Isn't it?
    – matt
    Nov 18, 2019 at 16:15
  • You can specify several filenames as a comma-separated (but without blanks!) list; cp. :help autocmd-patterns. Nov 18, 2019 at 16:20

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.