Before switching to vim years ago I was using Sublime Text and it perfectly handled situations when I just close it and open again. Nothing is lost and at the place where I left it off. So I'm aiming to reproduce that behaviour in Vim. What I have already is xolox/vim-session set up and running and swap files properly working as I expect them to. However, I encountered an issue that I create a new buffer without a name and it's not possible to restore it when I close vim and open it again. I would use a temporary file name as it mentioned here but I'm no so sure that this is the best approach to take.

So, my question is how to properly organize session save and restore even for unsaved buffers without a name?

  • If you use terminal Vim, I’d advocate using <C-z> or :suspend as a “close”—sessions (afaik) cannot keep unsaved unnamed buffers around. If you want to keep it, the text needs to stay in memory (background/foreground) or be saved. [this is a comment because i might be wrong] – D. Ben Knoble Feb 7 at 15:35
  • Hidden or unloaded buffers? Yes. Unsaved buffers? No, vim doesn't have a way to persist those in the session. Using a temporary file sounds as good as any other idea. (Unless backgrounding the process as D. Ben Knoble describes works for you.) – B Layer Feb 8 at 12:12

Your Answer

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

Browse other questions tagged or ask your own question.