Sublime Forum

Go to variable definition c++

#1

Hi guys,

I would like to use the go to definition feature to jump from a local variable to it’s definition. Lemme explain :

[code]#include

int test_function(int a)
{
return 2;
}

int main (int argc, char** argv)
{
int toto = 3;

return test_function(toto);

}[/code]

when I click on the second occurence of test_function, press F12 it jumps the first occurence, to the definition of test_function. However when I place the cursor on the second occurence of toto then press F12 ST says “unable to find toto”. :cry:

Is there a solution to this ? I always do Crtl+D many times to find the right one …

0 Likes

#2

I uses the CTags plugin.

0 Likes

#3

Hi jfcherng,

Thanks for answering, I already use CTags but it doesn’t go to the variable definition …
I did the CTag Rebuild tags
CTags show symbols works well
but the F12 on a local variable doesn’t do anything…
I use the version 0.4.0, someone seems to have the same problem on the website .

0 Likes

#4

CTags won’t catch local variable by default for C/C++.

$ ctags --list-kinds=c
c  classes
d  macro definitions
e  enumerators (values inside an enumeration)
f  function definitions
g  enumeration names
l  local variables [off]
m  class, struct, and union members
n  namespaces
p  function prototypes [off]
s  structure names
t  typedefs
u  union names
v  variable definitions
x  external and forward variable declarations [off]

To enable it, add the following parameter in your CTags’ setting file.
(Preferences -> Package Settings -> CTags -> Settings - User)

{
    ...

    // Additional options to pass to ctags, i.e.
    // ["--exclude=some/path", "--exclude=some/other/path", ...]
    "opts" : ["--c-kinds=+l"],

    ...
}
0 Likes

#5

We have been experimenting with rtags with great success.

1 Like