made '1. And '1 is made to '2, and so forth.
Mark '9 is lost.
The |:marks| command is useful to find out where '0 to '9 will take you.
GETTING BACK TO SOME FILE
If you want to go back to a file that you edited recently, but not when
exiting Vim, there is a slightly more complicated way. You can see a list of
files by typing the command: >
:oldfiles
< 1: ~/.config/nvim/init.vim ~
2: ~/text/resume.txt ~
3: /tmp/draft ~
Now you would like to edit the second file, which is in the list preceded by
"2:". You type: >
:e #<2
Instead of ":e" you can use any command that has a file name argument, the
"#<2" item works in the same place as "%" (current file name) and "#"
(alternate file name). So you can also split the window to edit the third
file: >
:split #<3
That #<123 thing is a bit complicated when you just want to edit a file.
Fortunately there is a simpler way: >
:browse oldfiles
< 1: ~/.config/nvim/init.vim ~
2: ~/text/resume.txt ~
3: /tmp/draft ~
-- More --
You get the same list of files as with |:oldfiles|. If you want to edit
"resume.txt" first press "q" to stop the listing. You will get a prompt:
Type number and <Enter> (empty cancels): ~
Type "2" and press <Enter> to edit the second file.
More info at |:oldfiles|, |v:oldfiles| and |c_#<|.
MOVE INFO FROM ONE VIM TO ANOTHER
You can use the ":wshada" and ":rshada" commands to save and restore the
information while still running Vim. This is useful for exchanging register
contents between two instances of Vim, for example. In the first Vim do: >
:wshada! ~/tmp/shada
And in the second Vim do: >
:rshada! ~/tmp/shada
Obviously, the "w" stands for "write" and the "r" for "read".
The ! character is used by ":wshada" to forcefully overwrite an existing
file. When it is omitted, and the file exists, the information is merged into
the file.
The ! character used for ":rshada" means that all the information in ShaDa
file has priority over existing information, this may overwrite it. Without
the ! only information that wasn't set is used.
These commands can also be used to store info and use it again later. You
could make a directory full of ShaDa files, each containing info for a
different purpose.
==============================================================================
*21.4* Sessions
Suppose you are editing along, and it is the end of the day. You want to quit
work and pick up where you left off the next day. You can do this by saving
your editing session and restoring it the next day.
A Vim session contains all the information about what you are editing.
This includes things such as the file list, window layout, global variables,
options and other information. (Exactly what is remembered is controlled by
the 'sessionoptions' option, described below.)
The following command creates a session file: >
:mksession vimbook.vim
Later if you want to restore this session, you can use this command: >
:source vimbook.vim
If you want to start Vim and restore a specific session, you can use the
following command: >
vim -S vimbook.vim
This tells Vim to read a specific file on startup. The 'S' stands for
session (actually, you can source any Vim script with -S, thus it might as
well stand for "source").
The windows that were open are restored, with the same position and size as
before. Mappings and option values are like before.
What exactly is restored depends on the 'sessionoptions' option. The
default value is:
"blank,buffers,curdir,folds,help,options,tabpages,winsize,terminal".
blank keep empty windows
buffers all buffers, not only the ones in a window
curdir the current directory
folds folds, also manually created ones
help the help window
options all options and mappings
tabpages all tab pages
winsize window sizes
terminal include terminal windows
Change this to your liking. To also restore the size of the Vim window, for
example, use: >
:set sessionoptions+=resize
SESSION HERE, SESSION