我最近在我的
vim配置中添加了NERDTree和NERDTreeTabs,我对此非常满意.
但是,我想进一步配置它并具有以下行为:
按Ctrl键:
>如果在NERDTree内,什么也不做.
>如果在编辑后的文件中,请转到打开的NERDTree,如果没有,则先打开一个NERDTree.我想应该使用NERDTreeTabsToggle,但要使用它,我必须能够检测NERDTree是否已经打开,而不是通过“切换”它来关闭它.
Ctrl右:
>如果在NERDTree内部,请返回已编辑的文件而不关闭NERDTree. (就像Ctrl-w一样,Right也会这么做.)
>如果在编辑的文件中,隐藏/关闭NERDTree.
但是,我的Vim脚本技能对我来说是很低的,以获得任何令人满意的结果.例如,我无法弄清楚如何检查当前活动窗口是什么或如何编写适当的条件语句.
有人可以帮助我吗?
谢谢.
解决方法
如果终于找到了办法.
我编辑了nerdtree_plugin / vim-nerdtree-tabs.vim文件,添加了以下功能:
" === Stepped Open/Close functions === " focus the NERDTree view,creating one first if none is present fun! s:NERDTreeSteppedopen() if !s:IsCurrentwindowNERDTree() if s:IsNERDTreeOpenInCurrentTab() call s:NERDTreeFocus() else call s:NERDTreeMirrorOrCreate() endif endif endfun " unfocus the NERDTree view or closes it if it hadn't had focus at the time of " the call fun! s:NERDTreeSteppedClose() if s:IsCurrentwindowNERDTree() call s:NERDTreeUnfocus() else let l:nerdtree_open = s:IsNERDTreeOpenInCurrentTab() if l:nerdtree_open silent NERDTreeClose endif endif endfun
我还向作者提出了一个pull-request问他是否想在上游添加这些功能.
作者将我的pull请求添加到主存储库,因此在下一个版本中,您可以直接调用这些函数.
希望它能帮到人们.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。