Pergunta

ctags -R dirName, vim -t tags is very powerful, since after these two commands, you can now have the ability to navigate between code of that project, for example you can just jump to the code of certain function using :tag functionName, but this operation still have some pitfalls, as is usual case that one source code could include some function calls such as va_start(), while this code is not included in the dirName directory, so indexs are not generated for this function, and you cannot navigate to the definition of va_start(), but it is needed to navigate to this function? how to find that code? i don't even know where va_start() is defined exactly. How do I generate ctags index for the system functions or function of third party?

Foi útil?

Solução

When you are using "ctags -R dirName" you are only indexing symbols for the content of the directory dirName.

What happens there is that "va_args" is defined in stdarg.h which is a header of the C standard library.

You'll encounter the same issue every time you'll be using a symbol from an external library.

So if you want to have all symbols available, you have, in addition to your program , to also index the code for external libraries.

It means :

  1. The source code should be available (which is not always the case)

  2. Once you have found on your system where the file is, it should be parsed to be included in your "tag" file.

So once you have executed ctags -R projectPath you can execute ctags -Ra /usr/include to append all the content of /usr/include to your tag file.

More generally you want to do something like ctags -Ra librarySourcePath to get all symbols used in your program available.

Edit : Be careful however : /usr/include might include lots of file, so the size of you tag file can greatly increase, and as consequence, every time you'll search for a symbol to jump to it, it could be much slower !

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top