top, so that you can read this text. The narrow
vertical window on the left contains a file explorer. This is a Vim plugin
that lists the contents of a directory. You can select files to edit there.
More about this in the next chapter.
Create this from a just started Vim with: >
:help
CTRL-W w
:vertical split ~/
You can resize the windows a bit to your liking. Then save the session with:
>
:mksession ~/.config/nvim/mine.vim
Now you can start Vim with this layout: >
vim -S ~/.config/nvim/mine.vim
Hint: To open a file you see listed in the explorer window in the empty
window, move the cursor to the filename and press "O". Double clicking with
the mouse will also do this.
SESSIONS AND SHADA
Sessions store many things, but not the position of marks, contents of
registers and the command line history. You need to use the shada feature
for these things.
In most situations you will want to use sessions separately from shada.
This can be used to switch to another session, but keep the command line
history. And yank text into registers in one session, and paste it back in
another session.
You might prefer to keep the info with the session. You will have to do
this yourself then. Example: >
:mksession! ~/.config/nvim/secret.vim
:wshada! ~/.local/state/nvim/shada/secret.shada
And to restore this again: >
:source ~/.config/nvim/secret.vim
:rshada! ~/.local/state/nvim/shada/secret.shada
==============================================================================
*21.5* Views
A session stores the looks of the whole of Vim. When you want to store the
properties for one window only, use a view.
The use of a view is for when you want to edit a file in a specific way.
For example, you have line numbers enabled with the 'number' option and
defined a few folds. Just like with sessions, you can remember this view on
the file and restore it later. Actually, when you store a session, it stores
the view of each window.
There are two basic ways to use views. The first is to let Vim pick a name
for the view file. You can restore the view when you later edit the same
file. To store the view for the current window: >
:mkview
Vim will decide where to store the view. When you later edit the same file
you get the view back with this command: >
:loadview
That's easy, isn't it?
Now you want to view the file without the 'number' option on, or with all
folds open, you can set the options to make the window look that way. Then
store this view with: >
:mkview 1
Obviously, you can get this back with: >
:loadview 1
Now you can switch between the two views on the file by using ":loadview" with
and without the "1" argument.
You can store up to ten views for the same file this way, one unnumbered
and nine numbered 1 to 9.
A VIEW WITH A NAME
The second basic way to use views is by storing the view in a file with a name
you choose. This view can be loaded while editing another file. Vim will
then switch