You restore the session by sourcing it with this command: :source ~/sessionname Vim will save your environment into this file to be asked for later. ~/sessionname can be any path and filename you like. You can save this setup with the following command: :mksession ~/sessionname It looks something like this: Say you are working on a project and you have all your buffers and windows and tabs and folds and marks set up just how you want them, but you need to quit Vim for some reason. You can use a Session to quickly switch between different projects, automatically loading the files you were last working on in that project. You can save a Session and when you restore it later the window layout looks the same. From :help session:Ī Session keeps the Views for all windows, plus the global settings. Later, you can load these things from that same file to restore your session just as you left it. 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. Hopefully if you’ve been keeping sessions at arm’s length up till now, there’ll be something in these posts that you’ll find useful.įirst, though, an introduction. It isn’t perfectly streamlined, but it does a lot of what I need with some (optional) small plugins and a minimum of damage to my ~/.vimrc. Now that I’ve dived in to sessions a little bit recently, I’d like to share the details of my setup over the course of a couple posts. These days I am rapidly switching among many feature branches, where I need a different set of files open in the same project depending on what feature or bugfix I’m working on. I’ve known about sessions in Vim for years, but until recently had never had enough need for them to overcome the relative difficulty of getting a proper workflow set up.
0 Comments
Leave a Reply. |