Usually I have many files open in a single tab and multiple tabs open in vim. But if I want to shut down the system and then resume the work, it’s really irritating to open all tabs and files again.
But vim has something amazing to help! Vim editor supports sessions just like some browsers.
This blog post will explain how to use vim sessions and how to use some plugins for vim session (specially required if you use NerdTree).
If you don’t use NerdTree :
You can easily save your current session in vim using:
#Now ~/ says to store the .vim in home, you can provide any path. :mksession ~/mysession.vim
and reopen it later using
#inside vim :source ~/mysession.vim #or in the terminal vim -S ~/mysession.vim
If you use NerdTree :
For some reason, :mksession fails to restore NERDTree buffers. As I also use NerdTree, so I would recommend you to use vim-session plugin. It also need vim-misc. Simply clone them and install them with vundle, as explained here.
Note: mksession will not save the changes to any files that you’ve made. So save the changes first.