Skip to content

Commit 702d22c

Browse files
committed
Merge pull request #35: Create session for current tab page only
I ported Ingo's code (based on vim-session 1.5) to vim-session 1.8 and changed quite a few things in the process: - Most significantly, in my version :OpenSession, :SaveSession and :CloseSession keep their original meaning and the commands :OpenTabSession, :SaveTabSession and :CloseTabSession should be used to manage tab scoped sessions. - Added documentation - Made periodic auto-save respect tab scoped sessions - Made lock files aware of tab scoped sessions and process IDs - Replaced set_session_name() with t:this_session / v:this_session - Auto-load functions for tab scoped commands, for easy re-use in command aliases - Renamed PushTabSessionOptions() to change_tab_options() - Renamed PopTabSessionOptions() to restore_tab_options() - Reimplemented session_name() as find_current_session() - Reimplemented is_tabsession() as is_tab_scoped() - xolox#session#save_session() now rewrites 'doautoall' in tab scoped sessions to 'windo doautocmd'
2 parents 96e547e + 51b8942 commit 702d22c

File tree

4 files changed

+378
-82
lines changed

4 files changed

+378
-82
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,34 @@ Note that this command only deletes the session script, it leaves your open tab
7272

7373
Execute this command to view the Vim script generated for a session. This command is useful when you need to review the generated Vim script repeatedly, for example while debugging or modifying the `session.vim` plug-in.
7474

75+
### Tab scoped sessions
76+
77+
When ['sessionoptions'] [sessionoptions] contains 'tabpages' (this is the default) session scripts will persist and restore all windows in all tab pages. When you remove 'tabpages' from ['sessionoptions'] [sessionoptions] you get a sort of light-weight sessions: They are constrained to a single tab page. Vim's [:mksession] [mksession] command and the vim-session plug-in both fully support this.
78+
79+
You can change ['sessionoptions'] [sessionoptions] in your [vimrc script] [vimrc] but then you can never save a session including tab pages. To decide on the spot whether you want a global or tab scoped session, the vim-session plug-in defines the three commands documented below.
80+
81+
Note that tab scoped sessions are regular session scripts, so when you load a tab scoped session using `:OpenSession` instead of `:OpenTabSession` the vim-session plug-in *assumes* it is a global session and will close all active tab pages before opening the tab scoped session.
82+
83+
#### The `:OpenTabSession` command
84+
85+
Just like `:OpenSession` but applies only to the current tab page.
86+
87+
#### The `:SaveTabSession` command
88+
89+
Just like `:SaveSession` but applies only to the current tab page.
90+
91+
#### The `:AppendTabSession` command
92+
93+
This command opens a new tab page and loads the given tab scoped session in that tab page. You can give this command a count just like [:tabnew] [tabnew].
94+
95+
#### The `:CloseTabSession` command
96+
97+
Just like `:CloseSession` but applies only to the current tab page.
98+
7599
## Options
76100

101+
The following Vim options and plug-in options (global variables) can be used to configure the plug-in to your preferences.
102+
77103
### The `sessionoptions` setting
78104

79105
Because the `session.vim` plug-in uses Vim's [:mksession][mksession] command you can change how it works by setting ['sessionoptions'][sessionoptions] in your [vimrc script] [vimrc], for example:
@@ -166,6 +192,13 @@ When this option is enabled the session plug-in will define the following comman
166192
* `SessionDelete` is an alias for `DeleteSession`
167193
* `SessionClose` is an alias for `CloseSession`
168194

195+
Then there are the command aliases for tab scoped sessions:
196+
197+
* `SessionTabOpen` is an alias for `OpenTabSession`
198+
* `SessionTabSave` is an alias for `SaveTabSession`
199+
* `SessionTabAppend` is an alias for `AppendTabSession`
200+
* `SessionTabClose` is an alias for `CloseTabSession`
201+
169202
The aliases support tab completion just like the real commands; they're exactly the same except for the names.
170203

171204
When you enable the aliases, the default command names will still be available. If you really don't like them, feel free to delete them using [:delcommand] [delcommand].
@@ -301,4 +334,5 @@ Here's an example session script generated by the `session.vim` plug-in while I
301334
[mksession]: http://vimdoc.sourceforge.net/htmldoc/starting.html#:mksession
302335
[sessionoptions]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27sessionoptions%27
303336
[source]: http://vimdoc.sourceforge.net/htmldoc/repeat.html#:source
337+
[tabnew]: http://vimdoc.sourceforge.net/htmldoc/tabpage.html#:tabnew
304338
[vimrc]: http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc

0 commit comments

Comments
 (0)