In vim, there is a feature which allows you to save your current session to a vimscript file. This can be done using the
:mksession command. Here is a synopsis of the command given in the vim documentation:
Write a Vim script that restores the current editing session.
When [!] is included an existing file is overwritten.
When [file] is omitted "Session.vim" is used.
You can then load a saved session by running
vim -S Session.vim. The
-S option will take the file given to it and source it before vim starts. (see
:h :source) Also, if you omit the file name from the
-S option, it will try to source a file in the current directory called
Session.vim. (only if
-S is given as the last argument and the file exists)
There is an option which allows you to specify what is saved in a session file as well, called
'sessionoptions'. This option is a comma separated list of words, with each word enabling the saving or restoring of something via the
:mksession command. Here is a list of the possible words in this option and what is saved for each one:
blank - empty windows
buffers - hidden and unloaded buffers, not just those in windows
curdir - the current directory
folds - manually created folds, opened/closed folds and local fold options
globals - global variables that start with an uppercase letter and contain at least one lowercase letter. Only String and Number types are stored.
help - the help window
localoptions - options and mappings local to a window or buffer (not global values for local options)
options - all options and mappings (also global values for local options)
resize - size of the Vim window: 'lines' and 'columns'
sesdir - the directory in which the session file is located will become the current directory (useful with projects accessed over a network from different systems)
slash - backslashes in file names replaced with forward slashes
tabpages - all tab pages; without this only the current tab page is restored, so that you can make a session for each tab page separately
unix - with Unix end-of-line format (single ), even when on Windows or DOS
winpos - position of the whole Vim window
winsize - window sizes
As an example, the default value for this option would be the following:
For more on these topics, see
:help :mksession and