0

I use ctags -R * to generate tag files. I have tried exuberant-ctags and universal-ctags. In a c function, I define a local variable, but ctags cannot find the definition of the local variable. Is there any options for ctags to generate tags for local variables?

2
  • 1
    Google "ctags local". First result has the answer.
    – B Layer
    Mar 2, 2021 at 2:08
  • (Also, try gd on that local variable)
    – D. Ben Knoble
    Mar 2, 2021 at 14:56

1 Answer 1

1

If you are using universal-ctags, pass --kinds-C=+l.

$ cat /tmp/foo.c
int
main(int argc, char **argv)
{
    int r = 0;
    retunr 0;
}
$ u-ctags -o - --kinds-C=+l /tmp/foo.c
main    /tmp/foo.c  /^main(int argc, char **argv)$/;"   f   typeref:typename:int
r   /tmp/foo.c  /^  int r = 0;$/;"  l   function:main   typeref:typename:int    file:
$ u-ctags -o - --kinds-C=+lz /tmp/foo.c
argc    /tmp/foo.c  /^main(int argc, char **argv)$/;"   z   function:main   typeref:typename:int    file:
argv    /tmp/foo.c  /^main(int argc, char **argv)$/;"   z   function:main   typeref:typename:char **    file:
main    /tmp/foo.c  /^main(int argc, char **argv)$/;"   f   typeref:typename:int
r   /tmp/foo.c  /^  int r = 0;$/;"  l   function:main   typeref:typename:int    file:
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.