我正在使用 vim 的“taglist”插件来导航项目中的源文件,但我遇到了处理 C++ 文件所特有的问题(与 C 不同;这可能会发生在其他语言(例如 Java)中) .
对于文件中的每个函数,它将显示两个标签:一个完全限定,另一个不是,即:
initialise [()]
ClassName::initialise [()]
update [()]
ClassName::update [()]
等等。这是可以理解的,因为我的 ctags 文件是使用 --extra=+q 生成的,如 ctags 手册页中所述,
Include[s] an extra class-qualified tag entry for each tag which is a member of a class (for languages for which this information is extracted; currently C++, Eiffel, and Java). The actual form of the qualified tag depends upon the language from which the tag was derived (using a form that is most natural for how qualified calls are specified in the language). For C++, it is in the form "class::member"; for Eiffel and Java, it is in the form "class.member". This may allow easier location of a specific tags when multiple occurrences of a tag name occur in the tag file. Note, however, that this could potentially more than double the size of the tag file.
因此,当我使用 Ctrl+] 进行导航等时,此设置对我很有用,因此我宁愿保留它,但我宁愿在标签列表菜单中删除合格的版本。我已经搜索了答案,但没有找到与此问题相关的任何内容;令人惊讶的是,我认为 OmniCPPComplete 建议使用 --extra=+q,所以我预计许多 C++ 程序员会使用它。
以下是我的 ctags 和 taglist 设置。任何帮助表示赞赏!
~/.ctags:
--c++-kinds=+p
--fields=+iaS
--extra=+q
~/.vimrc(提取标签列表设置)
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_Process_File_Always = 1
let Tlist_File_Fold_Auto_Close = 0
let Tlist_Enable_Fold_Column = 0
let Tlist_Use_Right_Window = 1
let Tlist_Show_One_File = 1
let Tlist_Ctags_Cmd = 'ctags'
最佳答案
答案就在我眼前!我没有意识到 taglist 实际上每次都运行自己的 ctags,而不仅仅是使用我的标签文件。我需要做的就是在 taglist 的 ctags 命令中显式禁用那些 C++ 特定设置:
let Tlist_Ctags_Cmd = 'ctags --extra=-q --c++-kinds=-p'
希望这篇文章对遇到同样问题的其他人有用!
关于c++ - Vim taglist 插件显示 C++ 标签两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7832175/