Depending on my task in Vim I have several tabs open.
How can I save different sessions for later use?
So if you only want to have only one session saved in your current directory, you can use :mksession or :mks from vim to save your current session, and just vim -S to open it back up.
Vim sessions work by saving info about your open buffers, windows, and other stuff to a Vim script file on your disk in a location you specify. Later, you can load these things from that same file to restore your session just as you left it.
You can save a session using the subroutine call syntax as follows: Vim::save_session():
You want something like
:mksession ~/mysession.vim
Then later you can source that vim file and you'll have your old session back:
:source ~/mysession.vim
or open vim with the -S option:
$ vim -S ~/mysession.vim
You might want to set these session options in your vimrc. Especially options is annoying when you've changed your vimrc after you've saved the session.
set ssop-=options " do not store global and local values in a session set ssop-=folds " do not store folds
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