Vim has a built-in session mechanism, from
A Session keeps the Views for all windows, plus the global settings. You can
save a Session and when you restore it later the window layout looks the same.
You can use a Session to quickly switch between different projects,
automatically loading the files you were last working on in that project.
It should fill your 2 first requirements but the third one
Sublime Text even remembers changes to unsaved files isn't supported out of the box.
To save your sessions you need to use
:h :mksession). By default the command will save the file in
./Session.vim but you can provide a file path as argument (e.g.
You can also modify the default behavior with
To reload your session use
:source ~/.Session.vim (or whatever filepath you used with
Note that you need Vim to be compiled with the
+mksession feature to use the sessions.
Finally to automate the process you can add this to your vimrc:
" Automatically save the session when leaving Vim
autocmd! VimLeave * mksession
" Automatically load the session when entering vim
autocmd! VimEnter * source ~/Session.vim
Edit 7 years later
As mentioned in the comments it might be better not to use the
VimEnter autocommand and trigger the sourcing manually to avoid sourcing the session in situations you don't want.
Or you could make the autocmd a bit smarted and source the session file only when you are in a specific directory.
Or you could have a shell alias like
alias lvim='vim -S ~/Session.vim' to start a session only when you want to. (That's the solution I ended up using in the long term)