如何使用\打开或关闭NERDTree和Tagbar?
我希望
在以下条件下打开或关闭 NERDTree 和 Tagbar:
- 仅当 NERDTree 和 Tagbar 都打开时才关闭两者
- 如果 NERDTree 和 Tagbar 都关闭或已经关闭则打开两者到目前为止
,在 VIMRC 中,我有:
nmap <leader>\ :NERDTreeToggle<CR> :TagbarToggle<CR>
这并不完全有效,因为如果一个打开,另一个关闭。它会打开关闭的那个并关闭打开的那个。
如何才能实现这一目标?
I want <leader>\
to open or close NERDTree and Tagbar, under the following conditions:
- Only close both if NERDTree and Tagbar are both opened
- Open both if NERDTree and Tagbar are closed OR if one is already opened
So far, in VIMRC, I have:
nmap <leader>\ :NERDTreeToggle<CR> :TagbarToggle<CR>
Which doesn't exactly work, since if one is opened, and the other closed. It would open the one that was closed and close the one that was opened.
How can this be achieved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用一个函数来检查插件窗口是否打开,然后采取相应的操作。这应该可以工作,并且还会跳回您开始的窗口:
You need to use a function that checks whether the plugin windows are open or not and then acts accordingly. This should work and will also jump back to the window that you started in:
嗯...这在 vimrc 中适用于我
切换选项检查窗口是否已经存在,因此不需要自定义函数(@JanLarres 或贡献者之一)必须将其添加到 TagBar :D
hmm... this works for me in vimrc
The toggle option checks if the window already exists, so no custom function needed (@JanLarres or one of the contributors) must have added it to TagBar :D