Home Explore Blog CI



neovim

12th chunk of `runtime/doc/starting.txt`
302b98bd0f9337d2071e970682270d8421ba44673a9173cc0000000100000fa6
 contains
   "options".  Script-local mappings will not be written.
2. Restores global variables that start with an uppercase letter and contain
   at least one lowercase letter, if 'sessionoptions' contains "globals".
3. Closes all windows in the current tab page, except the current one; closes
   all tab pages except the current one (this results in currently loaded
   buffers to be unloaded, some may become hidden if 'hidden' is set or
   otherwise specified); wipes out the current buffer, if it is empty and
   unnamed.
4. Restores the current directory, if 'sessionoptions' contains "curdir", or
   sets the current directory to where the Session file is, if
   'sessionoptions' contains "sesdir".
5. Restores GUI Vim window position, if 'sessionoptions' contains "winpos".
6. Restores screen size, if 'sessionoptions' contains "resize".
7. Reloads the buffer list, with the last cursor positions.  If
   'sessionoptions' contains "buffers" then all buffers are restored,
   including hidden and unloaded buffers.  Otherwise, only buffers in windows
   are restored.
8. Restores all windows with the same layout.  If 'sessionoptions' contains
   "help", help windows are restored.  If 'sessionoptions' contains "blank",
   windows editing a buffer without a name will be restored.
   If 'sessionoptions' contains "winsize" and no (help/blank) windows were
   left out, the window sizes are restored (relative to the screen size).
   Otherwise, the windows are just given sensible sizes.
9. Restores the Views for all the windows, as with |:mkview|.  But
   'sessionoptions' is used instead of 'viewoptions'.
10. If a file exists with the same name as the Session file, but ending in
   "x.vim" (for eXtra), executes that as well.  You can use `*x.vim` files to
   specify additional settings and actions associated with a given Session,
   such as creating menu items in the GUI version.

After restoring the Session, the full filename of your current Session is
available in the internal variable |v:this_session|.
An example mapping: >
  :nmap <F2> :wa<Bar>exe "mksession! " .. v:this_session<CR>:so ~/sessions/
This saves the current Session, and starts off the command to load another.

A session includes all tab pages, unless "tabpages" was removed from
'sessionoptions'. |tab-page|

The |SessionLoadPost| autocmd event is triggered after a session file is
loaded/sourced.
						*SessionLoad-variable*
While the session file is loading, the SessionLoad global variable is set to
1.  Plugins can use this to postpone some work until the SessionLoadPost event
is triggered.

							*:mkvie* *:mkview*
:mkvie[w][!] [file]	Write a Vim script that restores the contents of the
			current window.
			When [!] is included, an existing file is overwritten.
			When [file] is omitted or is a number from 1 to 9, a
			name is generated and 'viewdir' prepended.  When the
			last path part of 'viewdir' does not exist, this
			directory is created.  E.g., when 'viewdir' is
			"$VIM/vimfiles/view" then "view" is created in
			"$VIM/vimfiles".
			An existing file is always overwritten then.  Use
			|:loadview| to load this view again.
			When [file] is the name of a file ('viewdir' is not
			used), a command to edit the file is added to the
			generated file.

The output of ":mkview" contains these items:
1. The argument list used in the window.  When the global argument list is
   used, it is reset to the global list.
   The index in the argument list is also restored.
2. The file being edited in the window.  If there is no file, the window is
   made empty.
3. Restore mappings, abbreviations and options local to the window, if
   'viewoptions' contains "options" or "localoptions".  Only option values
   that are local to the current buffer and the current window are restored.
   When storing the view as part of a session and "options" is in
   'sessionoptions', global values for local options will be stored too.
4. Restore folds when using manual folding and 'viewoptions' contains

Title: Session Restoration Details, x.vim Files, and mkview Command
Summary
This section provides a detailed breakdown of what the ':mksession' command restores based on the 'sessionoptions' setting, including global mappings, variables, window layout, buffer list, window sizes, and Views. It introduces the concept of 'x.vim' files for specifying additional settings for a session. It also discusses the ':mkview' command, which writes a script to restore the contents of the current window.