I left some files opened in gVim, and hibernated my machine.

Unfortunately, there was some error, and I lost my gVim session.

Is it possible to do like modern browsers nowadays (like Firefox), that after "crashing" (not exiting in normal ways), showing a "Restore last session" dialog in my gVim?


One possibility would be to run :mksession periodically. Vim does not support timers as far as I know, but you could associate :mksession to a :autocmd event such as BufNewFile.

A possible event to use in these cases is VimLeavePre, e.g.:

autocmd VimLeavePre * mksession! .vim.sess

If you want another hint, or something that is more user friendly and asks you at start up if you want to load the session, you could give a try to http://www.vim.org/scripts/script.php?script_id=3150 . I use it and it works quite well for me. You can have multiple sessions and it is very user friendly. You can SaveSession, OpenSession, DeleteSession and the files are stored in .vim/sessions so that you can use still mksession if you want.

  • I'm with too many plugins already, I started using builtin functions for some stuff... but thanks for the suggestion! – Somebody still uses you MS-DOS Dec 5 '12 at 3:33

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.