Vi/Vim restore opened files

Viewed 23275

I was wondering if this common IDE feature is available.

Suppose I open many files using Vim, using vsplit and split. Then, I close everything.

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

9 Answers

My solution is as below, put them in .vimrc file. HTH.

" session related.
" Default session is located `~/.session_'. The suffix `_' is a dirty
" solution, just like the one-element tuple `(tuple_eliment,)' in Python..
cnoremap <C-O> source ~/.session_
cnoremap <C-S> mksession! ~/.session_
nnoremap <silent> <C-S><C-S> :mksession! ~/.session_ <CR>

Seems to be more complex, but very useful if you have multiple sessions to save and load.

P.S.
Here, I adopt the familiar <Ctrl-S> and <Ctrl-O> shortcuts, to save and load sessions. IMHO, this is more comfortable than reaching out my hand to <Fn> key. ;-)

Related