tags:

views:

558

answers:

5

Hi,

I was wondering if this common IDE feature is available.

Suppose i open many files using VIM, using vsplit and split. Then , I close everthing.

The next day, i want to recover those files. That is, recover the way they were opened, not having to open each one (using split and vsplit) again.

Is that possible?

UPDATE:

Using :mksession! and source commands, mapping commands in .vimrc file, is there a way to parameterize mappings so as to write a specific file?

for example:

map <F2> :mksession! ~/vim_session @INSERT_HERE<cr> "Save session to @INSERTHERE file

Thanks in advance

+7  A: 

Give a look at the :mksession command, to create a session:

A Session keeps the Views for all windows, plus the global settings. You can save a Session and when you restore it later the window layout looks the same. You can use a Session to quickly switch between different projects, automatically loading the files you were last working on in that project.

CMS
Thanks ,looks quite useful
Tom
+11  A: 

You can map using :mksession and :source to a set of keys for easy saving and restoring. Here's an example from my .vimrc that uses F2 and F3:

map <F2> :mksession! ~/vim_session <cr> " Quick write session with F2
map <F3> :source ~/vim_session <cr>     " And load session with F3
hgimenez
Nice one , thanks!
Tom
consider naming the file ~/.vim_session, too, so it's out of the way. this is more consistent with its function, too.
Peter
+1  A: 

You might be interested in this book:

http://www.swaroopch.com/notes/Vim#Download

It's one of the first few things they show you as an example of how great Vim is. ;)

Also, <cr> stands for Carriage Return.

jluebbert
Thanks, realized about the <cr> about 10 seconds after asking :p
Tom
+1  A: 

You could consider using GNU Screen. In short: it's a command line Window Manager that allows a user to access multiple separate terminal sessions inside a single terminal session. The main advantage to me is that you can detach the session, close your terminal window, and later re-attach the session, and continue working.

klokop
A: 

SessionMan http://www.vim.org/scripts/script.php?script_id=2010 offers easier functionality. Be careful with miniBufExplorer. It's incompatible unless you use the modified version made by andrew on vim_use (and even then, it's only halfway compatible)

autodidakto