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?

link|improve this question

feedback

1 Answer

up vote 3 down vote accepted

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
link|improve this answer
Do you mean associating :mksession each time I use :w for example? – Somebody still uses you MS-DOS Jun 4 '10 at 13:28
1  
just as a hint (because :mksession is correct): vim.org/scripts/script.php?script_id=2010 – akira Jun 4 '10 at 19:35
yep that's what I meant – UncleZeiv Jun 6 '10 at 16:22
I did a different solution, but using a similar concept that you suggested: autocmd VimLeavePre * mksession! .vim.sess I think it would be a good idea to you to edit your answer and add the VimLeavePre approach! jaredforsyth.com/blog/2010/apr/9/vim-crash-recovery – Somebody still uses you MS-DOS Jun 8 '10 at 13:05
Enabling just that autocmd and adding -S to the gVim startup command will enable automatic session management! Thanks guys. – Merijn May 12 '11 at 6:15
feedback

Your Answer

 
or
required, but never shown

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