Monday, June 6, 2011

Autosaving Vim sessions

Accidentally closing a Vim window with several open files can mean losing a lot of state.  Reopening all files again to continue editing can be daunting, if not in real at least while thinking about it.  Add the following line to your .vimrc:
autocmd VimLeave * mksession! ~/.vim/last-session.vim
You can resume an accidentally closed Vim session by using the command:
vim -S ~/.vim/last-session.vim

No comments:

Post a Comment