打开某些文件类型时启动 VIM Tagbar
我希望在打开某些文件类型时启动 tagbar VIM 插件,因此我将以下内容添加到我的 .vimrc 中:
if has("gui_running")
autocmd BufEnter *.hs nested TagbarOpen
但是,这并没有按我的预期工作。它打开一个侧窗,但侧窗什么也不显示,我的光标被困在里面。我无法通过单击或使用 CTRL-W 移动命令来切换窗口。
但是,当我手动运行 TagbarOpen 时,它工作得很好。
其他人尝试过这个,或者上面的命令是错误的?
I'd like to have the tagbar VIM plugin launch when I open certain filetypes, so I added the following to my .vimrc:
if has("gui_running")
autocmd BufEnter *.hs nested TagbarOpen
However, this isn't working as I expected. It opens a side window, but the side window displays nothing and my cursor is trapped within it. I cannot switch windows with a click or with the CTRL-W movement commands.
However, when I run TagbarOpen manually, it works just fine.
Anyone else tried this, or is the above the wrong command to issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有趣的是,这是我没有预料到的便利功能的副作用。发生的情况是这样的:如果在窗口已经打开的情况下调用 TagbarOpen,Tagbar 会使光标跳转到其窗口,而不是什么也不做(就像我说的为了方便)。因此,每次您尝试通过切换到 Haskell 窗口来离开窗口时,自动命令都会使其立即跳回来。我已经推动了一项删除此功能的更改——一开始它可能没有那么有用。因此,如果您尝试 GitHub 上的开发版本 (https://github.com/majutsushi/tagbar ),它应该可以工作。
窗口为空有不同的原因:Exuberant Ctags 默认不支持 Haskell。但有人为 Haskell 写了一个很好的替代方案,可以与 Tagbar 一起使用:https://github.com/bitc/lushtags。
Interesting, that's a side effect of a convenience functionality that I hadn't anticipated. What happens is this: If TagbarOpen is called while the window is already open, Tagbar makes the cursor jump to its window instead of just doing nothing (for convenience like I said). So every time you try to leave the window by switching to the Haskell window, the autocommand causes it to jump right back. I've pushed a change that removes this functionality -- it probably wasn't that useful to begin with. So if you give the development version on GitHub a try (https://github.com/majutsushi/tagbar), it should work.
That the window is empty has a different reason: Haskell is not supported by Exuberant Ctags by default. But someone wrote a nice alternative for Haskell that works with Tagbar here: https://github.com/bitc/lushtags.
实际上,我已经为 php 文件设置了 vimrc 的确切配置。标签栏打开并加载函数/变量,Vim 加载时光标停留在 php 源文件中:
将 'php' 替换为 'hs' 或您想要的任何其他文件类型。文件类型列表位于:
让它在 MacVim 上运行(快照 72、Vim 7.4),以及来自 https:// /github.com/majutsushi/tagbar
I actually have this exact configuration set up my vimrc for php files. Tagbar opens with function / variables loaded, cursor stays in php source file when Vim loads:
substitute 'php' for 'hs' or any other file type you want. List of filetypes at:
Have it running on MacVim (snapshot 72, Vim 7.4), and latest build of tagbar from https://github.com/majutsushi/tagbar