I usually have long lived vim session with dozens of files open. Once in a while, I need to restart vim, say to install a new plugin or apply some new config.
How can I reopen all the previous files after restart?
You can use builtin sessions, perhaps with vim-session plugin.
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.)
The command
:mksession mysession.vim
saves the current session into the named file. Next time you start vim you can load the session:
vim -S mysession.vim
or inside vim
:source mysession.vim
You can automate saving sessions on VimLeave autocommand and reload a session on VimEnter but be careful abut restoring a session when vim is called, e.g., from git.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With