Save your vim session while working on a lot of files opened in different tabs or screens by using
in one of the vim windows. Note that it does not have to have “
After that you can do pretty much anything with your computer (close all windows, reboot, etc.) as long as you do not deleted the file saved above. You can restore the session while you are in vim by using:
or if you want to start vim with the saved session, use this
$ vim -S saved_session.vim
in the command line.
Application: (Directly copied from here)
The obvious way to use sessions is when working on different projects.
Suppose you store you session files in the directory "~/.vim". You are
currently working on the "secret" project and have to switch to the "boring"
This first uses ":wall" to write all modified files. Then the current session
is saved, using ":mksession!". This overwrites the previous session. The
next time you load the secret session you can continue where you were at this
point. And finally you load the new "boring" session.
Further reading: here and here.