Vim、NERDtree 未在会话还原中恢复 [英] Vim, NERDtree not recovered in session restore

查看:31
本文介绍了Vim、NERDtree 未在会话还原中恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我有一个 NERDtree 面板并保存一个 Vim 会话(mksession [文件名]),然后打开该会话(vim -S 文件名)时,该面板被打开并标记为NERDtree"但没有填充.如果我从命令行尝试:NERDtree",窗口会被填充,但现在会打开另一个面板.

When I have a NERDtree panel and I save a Vim session (mksession [filename]), then open the session (vim -S filename), the panel is opened and tagged "NERDtree" but is not populated. If I try ":NERDtree" from the commandline, the window does get populated, but another panel now opens.

对这种奇怪的行为有什么想法吗?

Any ideas wrt this weird behaviour?

推荐答案

刚刚决定自己处理这个问题.就我而言,会话是在我退出 Vim 时在 vimrc 中创建的:

Just decided to deal with this very issue myself. In my case, the session is created when I quit Vim with the following in my vimrc:

autocmd VimLeave * mksession![文件名]

我还尝试在 Vim 打开时自动打开 NERDTree:

I was also trying to open NERDTree automatically when Vim opened with:

autocmd VimEnter * NERDTree

结果是我的会话以两个 NERDTree 实例打开,如原始帖子中所述.我的解决方案是在保存会话之前简单地关闭 NERDTree,这样我的自动打开调用只会打开 NERDTree 的一个实例.

The result was that my session opened with two instances of NERDTree, like described in the original post. My solution was to simply close NERDTree before saving the session, that way my auto-open call would only open the one instance of NERDTree.

我的解决方案

" Save session on quitting Vim
autocmd VimLeave * NERDTreeClose
autocmd VimLeave * mksession! [filename]

" Restore session on starting Vim
autocmd VimEnter * call MySessionRestoreFunction()
autocmd VimEnter * NERDTree

到目前为止,它对我来说就像一种魅力.希望这会有所帮助.

It's working like a charm for me so far. Hope this helps.

这篇关于Vim、NERDtree 未在会话还原中恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆