vim - Sessions

Vim is text editor built to create/modify text based files. It is quite powerful and customizable.

Vim can be used on mostly any Unix based computers and on Mac OS X.

Getting the vim on your computer

Alright, in case you skiped a few steps in this vim tutorial series, here is how you install vim on your computer

On a Debian base distribution, do the following.
# apt-get install vim
On ArchLinux based distibution, do the following.
# pacman -S vim

Note: if you want to learn the basics you can visit vim - Basics

Create a session

Creating a session allows you to close vim and open it back in the exact same state. This is a great feature when you have multiple files opened. (What a pain opening back all your project files.)

Alright, how does this works?

To create your session, you need to type this simple command. (Of course, if you are in a particular mode you need to exit it by pressing the escape button on your keyboard.)

:mks ~/.vim/sessions/project1.vim

Wow what a great system. With it you can simply create as many sessions you want (I'm talking to you Mrs./Mr. Programmer with many projects on the go).

Well that's nice, but how do I load back my session. It's quite easy. Simply type the following:

:source ~/.vim/sessions/project1.vim

or directly from the command line.

$ vim -S ~/.vim/sessions/project1.vim

Conclusion

You want to know more cool feature from vim have a look at my other vim tutorials.

Sources

  1. Julia Evans' Twitter Post
  2. Stack Overflow - How to save and restore multiple different sessions in Vim?