When Vim starts, it always opens buffers of last session too. That is to say, when I leave Vim by closing all windows, but do not explicitly close buffers (by :bd), those buffers will be opened next time Vim starts. How can I not open these buffers?

  • I find it irritating because sometimes I close Vim to edit files with other programs, or rename them. Since Vim keeps opening them, afterwards I reopen Vim, falsely thinking these files are not being opened, there will be swap files, which I must take time to deal with. – Violapterin Jun 29 '17 at 14:03
  • This is not the default behavior. Does it behave the same when you start Vim with vim -u NONE? – Tumbler41 Jun 29 '17 at 14:35
  • 2
    Oh... when I open with vim -u NONE, this no longer happens. I think I have to comment out my vimrc one by one, to debug the problem.... – Violapterin Jun 29 '17 at 15:50
  • what is your 'viminfo' setting? – Christian Brabandt Jun 29 '17 at 17:06
  • 1
    @Aminopterin There you have it: :h viminfo-% – Christian Brabandt Jun 29 '17 at 20:56

This might be caused by the 'viminfo' setting containing the "%" item. If the "%" flag is included in your viminfo setting, this means:

When included, save and restore the buffer list. If Vim is started with a file name argument, the buffer list is not restored. If Vim is started without a file name argument, the buffer list is restored from the viminfo file. Quickfix ('buftype'), unlisted ('buflisted'), unnamed and buffers on removable media (viminfo-r) are not saved. When followed by a number, the number specifies the maximum number of buffers that are stored. Without a number all buffers are stored.

  • I think there should be best a warning that tells the user not to copy other's vimrc mindlessly XD Originally my vimrc was littered with whatever I copied from other people, in the very start of my learning Vim. That way, I had spent many hours debugging strange things. – Violapterin Jul 2 '17 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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