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
You can use the :edit command, without specifying a file name, to reload the current file. If you have made modifications to the file, you can use :edit! to force the reload of the current file (you will lose your modifications). The command :edit can be abbreviated by :e . The force-edit can thus be done by :e!
You can use :sh to exit to your default shell then typing $ exit at the shell prompt will return you to Vim.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With