Home Explore Blog CI



neovim

13th chunk of `runtime/doc/starting.txt`
6cef8c511aceaf01a633949326702b497eb38ce57612ceff0000000100000fa2
 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
   "folds".  Restore manually opened and closed folds.
5. The scroll position and the cursor position in the file.  Doesn't work very
   well when there are closed folds.
6. The local current directory, if it is different from the global current
   directory and 'viewoptions' contains "curdir".

Note that Views and Sessions are not perfect:
- They don't restore everything.  For example, defined functions, autocommands
  and ":syntax on" are not included.  Things like register contents and
  command line history are in ShaDa, not in Sessions or Views.
- Global option values are only set when they differ from the default value.
  When the current value is not the default value, loading a Session will not
  set it back to the default value.  Local options will be set back to the
  default value though.
- Existing mappings will be overwritten without warning.  An existing mapping
  may cause an error for ambiguity.
- When storing manual folds and when storing manually opened/closed folds,
  changes in the file between saving and loading the view will mess it up.
- The Vim script is not very efficient.  But still faster than typing the
  commands yourself!

							*:lo* *:loadview*
:lo[adview] [nr]	Load the view for the current file.  When [nr] is
			omitted, the view stored with ":mkview" is loaded.
			When [nr] is specified, the view stored with ":mkview
			[nr]" is loaded.

The combination of ":mkview" and ":loadview" can be used to store up to ten
different views of a file.  These are remembered in the directory specified
with the 'viewdir' option.  The views are stored using the file name.  If a
file is renamed or accessed through a (symbolic) link, the view will not be
found.

You might want to clean up your 'viewdir' directory now and then.

To automatically save and restore views for `*.c` files: >
	au BufWinLeave *.c mkview
	au BufWinEnter *.c silent! loadview

==============================================================================
Shada ("shared data") file			*shada* *shada-file*

If you exit Vim and later start it again, you would normally lose a lot of
information.  The ShaDa file can be used to remember that information, which
enables you to continue where you left off.  Its name is the abbreviation of
SHAred DAta because it is used for sharing data between Nvim sessions.

This is introduced in section |21.3| of the user manual.

The ShaDa file is used to store:
- The command line history.
- The search string history.
- The input-line history.
- Contents of non-empty registers.
- Marks for several files.
- File marks, pointing to locations in files.
- Last search/substitute pattern (for 'n' and '&').
- The buffer list.
- Global variables.

You could also use a Session file.  The difference is that the ShaDa file
does not depend on what you are working on.  There normally is only one
ShaDa file.  Session files are used to save the state of a specific editing
Session.  You could have several Session files, one for each project you

Title: mkview Output Details, Limitations, loadview Command, and Shada Files
Summary
This section details the contents of the output generated by the ':mkview' command, including argument lists, file information, mappings, folds, and cursor positions. It notes limitations of Views and Sessions, such as handling of functions, autocommands, and global option values. It introduces the ':loadview' command for loading saved views. The section transitions to explain ShaDa files, which store information between Vim sessions like command history, registers, marks, buffer lists, and global variables, contrasting them with Session files.