简体   繁体   English

Vim c++ 区分同名符号的索引

[英]Vim c++ indexing that differentiates between symbols with same names

I've been trying out vim with exuberant tags and cscope but when listing the usages of a variable it also lists variables with the same name that aren't really the symbol I'm looking at.我一直在尝试使用 vim 和 exuberant 标签和 cscope,但是在列出变量的用法时,它还会列出具有相同名称的变量,这些变量并不是我正在查看的符号。 For example if I want to jump to the declaration or other usages of a variable called "temp", it will give me all variables called "temp" in the whole repo.例如,如果我想跳转到名为“temp”的变量的声明或其他用法,它将给我整个仓库中所有名为“temp”的变量。 Am I using tags and cscope wrong or is there another plugin I should be using instead?我使用的标签和 cscope 是错误的还是我应该使用另一个插件?

Ctags and cscope use parsers and even regular expressions to find symbols in files. Ctags 和 cscope 使用解析器甚至正则表达式来查找文件中的符号。 They "understand" syntax, in a way, but they don't understand code so they have no idea about what specific function is called where.他们在某种程度上“理解”语法,但他们不理解代码,因此他们不知道具体的 function 在哪里被调用。

Consequently…最后…

  • that relationship is not encoded in the resulting database,该关系未编码在生成的数据库中,
  • and it is lost to any program using ctags or cscope.并且它会丢失给任何使用 ctags 或 cscope 的程序。

If you want a tool that knows exactly which temp is referenced, then you don't want csope or ctags.如果您想要一个准确知道引用了哪个temp的工具,那么您不需要 csope 或 ctags。 You want something based on a compiler, like clang.你想要一些基于编译器的东西,比如 clang。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM