Vim

Vim sessions

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s