Sessions are a built-in feature of vim to allow you to quickly restore buffers and window layouts to a viminfo-file. These files can be reused and can usually be transferred to other machines. This is particularly nice if you have many config files across the system where the location is hard to remember, or if you like your window layout a certain way every time.
In my example below I will show how I like to setup some Session files for OBIEE.
:help sessions
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.
OBIEE Config example
In this example we will create a session with three config files.
Setup
Start off in the base config directory
$ cd $ORACLE_HOME/user_projects/domains/bi/config/fmwconfig
Edit the first file
$ vim biconfig/OBIPS/instanceconfig.xml
In vim, split the window and edit the second tile.
Tip: Tab-completion can work here.
:sp biconfig/OBIS/NQSConfig.INI
Now create a vertical-split with the last file
:vsp biconfig/OBISCH/schedulerconfig.xml
Your setup should look a lot like this
Create
Create the Session file (this will save to the home directory)
:mks ~/biConfigs.vim
Quit all buffers
:qall
Restore
Now from anywhere in the file system you can restore that session.
$ vim -S ~/biConfigs.vim
-S {file} {file} will be sourced after the first file has been read. This is equivalent to -c “source {file}”. {file} cannot start with ‘-’. If {file} is omitted “Session.vim” is used (only works when -S is the last argument).
Even better, you can create an alias for the above command. Add the alias to your .bashrc/.bash_profile to always have the command ready.
$ alias biConfigs='vim -S ~/biConfigs.vim'
$ biConfigs
Other tips
- Create a session file for logging configs
- Create a session file for datasource files: odbc.ini, tnsnames.ora
- Add the session files to an NFS mount and have them available in all your environments