Vim editor Tips – Auto saving vim sessions

 

Vim editor Tips – Auto saving vim sessions

If accidentally we closing a Vim window with several open files can mean losing a lot of state.  Reopening all files again to continue editing can be difficult, 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 following  command:

 vim -S ~/.vim/last-session.vim