Vim Sessions
Posted by ajay on October 15, 2009
Vim editor also supports sessions just like a browser like firefox.
If you have 8-10 tabs having > 30 files open in vim [ this should be the case if you’re working on a project of reasonably big size] , and you have to reboot your PC or restart x server for that matter, it can get really irritating to close vim, and then open files one by one again :(.
Vim session solve exactly this problem. When you have to close your vim for any such thing, you can just do
:mksession /path/to/session/file.vim
This will store everything in current vim session including all open files, all visible buffers, window sizes and keyboard mappings etc.
Now when you want to restore vim from this particular session, you can just do
command_prompt$ vim -S /path/to/session/file.vim
This will restore everything just the way it was :).
You should have vim compiled with session support in order to be able to do this. I think from version 7 onwards, even the standard vim supports this by default. Also, for the setting to work, you need to add the following line to your .vimrc
set sessionoptions=blank,buffers,curdir,folds,globals,help,localoptions,options,resize,tabpages,winsize,winpos
PS: Vim session doesnt keep track of undo history in each open file.
Kuba said
Thanks for this tip! Why I didn’t know about it before? You even don’t realize how many times it could make my life easier.
Sai Mukund Sagar said
Thanks a lot dude!! Really nice tip..
nitin said
hi i am kamal from kanpur.you knew that you have ten tabs having greater than 29 files open in vim and you have to reboot your PC or restart x server for that matter, it can get really irritating to close vim, and then open files respectively.
==================================================================================================
Jakub said
Thanks, really useful 🙂
Louisa said
You’re the grettesa! JMHO
http://goanalyze.info/oz.by said
I tried pure mango slim thinking that it will help me in increasing the metabolism and reducing my effort in losing inches but I am afraid there were no such results even after consuming two bottles of pure mango slim.VA:F [1.9.21_1169]please wait…
Venice, CA auto insurancies said
Methuser, you need help for your self-loathing and drug problem. You are obviously posting here under the influence of drugs. Get help before you kill yourself.
pinterest.com said
2,600 miles on a Honda – part 4
revida putri said
Yesterday, while I was at work, my sister stole my iPad and tested to see if it
can survive a 40 foot drop, just so she can be a youtube sensation. My iPad is now
destroyed and she has 83 views. I know this is entirely off topic but I had to
share it with someone!
revida putri said
Good day very cool website!! Guy .. Excellent ..
Superb .. I’ll bookmark your web site and take the
feeds also? I am glad to seek out a lot of useful information right here within the publish, we
need develop extra techniques in this regard, thanks for
sharing. . . . . .
toyota said
Very good article. I certainly love this website. Thanks!