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. 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. Am I using tags and cscope wrong or is there another plugin I should be using instead?
Asked
Active
Viewed 64 times
-1
-
Yes, you're using tags wrong. You should read `:h definition-search` and `:h include-search` to learn the plethora of shortcuts to go to declarations and usages (also called "references"). ctags is a smarter tool in a way, but also more general. – r_31415 Aug 03 '22 at 05:57
1 Answers
0
Ctags and cscope use parsers and even regular expressions to find symbols in files. They "understand" syntax, in a way, but they don't understand code so they have no idea about what specific function is called where.
Consequently…
- that relationship is not encoded in the resulting database,
- and it is lost to any program using ctags or cscope.
If you want a tool that knows exactly which temp
is referenced, then you don't want csope or ctags. You want something based on a compiler, like clang.

romainl
- 186,200
- 21
- 280
- 313