You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-2Lines changed: 20 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ This command saves your current editing session just like Vim's built-in [:mkses
30
30
31
31
If the session you're trying to save is already active in another Vim instance you'll get a warning and nothing happens. You can use a bang (!) as in `:SaveSession! ...` to ignore the warning and save the session anyway.
32
32
33
-
As mentioned earlier your session script will be saved in the directory pointed to by `g:session_directory`.
33
+
Your session script will be saved in the directory pointed to by the `g:session_directory` option.
34
34
35
35
### The `:OpenSession` command
36
36
@@ -74,14 +74,22 @@ Execute this command to view the Vim script generated for a session. This comman
74
74
75
75
### The `sessionoptions` setting
76
76
77
-
Because the `session.vim` plug-in uses Vim's [:mksession][mksession] command you can change how it works by setting ['sessionoptions'](http://vimdoc.sourceforge.net/htmldoc/options.html#%27sessionoptions%27) in your [vimrc script][vimrc], for example:
77
+
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:
78
78
79
79
" If you only want to save the current tab page:
80
80
set sessionoptions-=tabpages
81
81
82
82
" If you don't want help windows to be restored:
83
83
set sessionoptions-=help
84
84
85
+
Note that the session.vim plug-in automatically and unconditionally executes the following changes just before saving a session:
86
+
87
+
" Don't persist options and mappings because it can corrupt sessions.
88
+
set sessionoptions-=options
89
+
90
+
" Always persist Vim's window size.
91
+
set sessionoptions+=resize
92
+
85
93
### The `g:session_directory` option
86
94
87
95
This option controls the location of your session scripts. Its default value is `~/.vim/sessions` (on UNIX) or `~\vimfiles\sessions` (on Windows). If you don't mind the default you don't have to do anything; the directory will be created for you. Note that a leading `~` is expanded to your current home directory (`$HOME` on UNIX, `%USERPROFILE%` on Windows).
@@ -98,6 +106,15 @@ By default this option is set to `'prompt'`. When you've opened a session and yo
98
106
99
107
By default this option is set to false (0). When you set this option to true (1) and you start Vim, the session plug-in will open your last used session instead of the default session. Note that the session plug-in will still show you the dialog asking whether you want to restore the last used session. To get rid of the dialog you have to set `g:session_autoload` to `'yes'`.
100
108
109
+
### The `g:session_persist_globals` option
110
+
111
+
The session.vim plug-in uses Vim's [:mksession][mksession] command but it changes ['sessionoptions'][sessionoptions] so that Vim options and mappings are not persisted. The plug-in does this because persistence of options and mappings can break loading of sessions, in other words it's fragile (in my opinion).
112
+
113
+
If you want the plug-in to persist specific global variables or options you can add their names to the list `g:session_persist_globals` in your [vimrc script][vimrc]:
114
+
115
+
" Persist the value of the global option 'makeprg'.
116
+
call add(g:session_persist_globals, '&makeprg')
117
+
101
118
### The `g:session_restart_environment` option
102
119
103
120
This option is a list of environment variable names (without the dollar signs) that the `:RestartVim` command will pass on to the new instance of Vim. This option is only useful on UNIX. By default the three environment variables `$TERM`, `$VIM` and `$VIMRUNTIME` are included in this list.
@@ -231,3 +248,4 @@ Here's an example session script generated by the `session.vim` plug-in while I
0 commit comments