0

I have autocmd BufEnter * silent! lcd %:p:h in my .vimrc so that the current buffer's pwd is always set correctly. Unfortunately mksession does not save sessions properly because of this.

Is there either a better way to save sessions, or a way to make these two features play together well? Disabling the autocmd temporarily with :noautocmd mksession session1 doesn't seem to work.

4

2 回答 2

3
:set autochdir

将与您的 autocmd 执行相同的操作,并且是内置的。我自己正在使用那个,并且没有遇到任何会话问题。当然,保存会话的目录必须相对于当前文件指定,尽管您可以定义:Mksession始终基于固定目录的自定义命令。

于 2014-06-23T06:25:25.313 回答
1

来自:help

                        *SessionLoad-variable*
While the session file is loading the SessionLoad global variable is set to 1.
Plugins can use this to postpone some work until the SessionLoadPost event is
triggered.

如果g:SessionLoad存在并设置为 1,您可以尝试修改您的 autocmd 以不执行任何操作。

但我认为 Ingo 的解决方案,使用set autochdir,更好。

于 2014-06-23T13:46:30.773 回答