I’m browsing some C code.
I ran into a variable that is defined in a header file.
How can i move my cursor under this variable and jump to see its definition ?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Achieving this in vim can be done by using a tag file.
You can generate a tag file with the
ctagsorexhuberant-ctagsprogram.cd in the directory of your project and run:
This will generate a file named
tagsthat contain a list of all symbols in your source code, with their location.Vim knows how to use these files to get you to the correct location. When your cursor is over a symbol, just hit
CTRL-]to get to its definition. And you can return where you were by hittingCTRL-T.See
:help tags,:help CTRL-]and:help CTRL-TVim can use multiple tag files at the same time. For example you could have one for your project and one for each library you use. For this, just generate the various tag files and add them in the
tagssetting:./tags,./TAGS,tags,TAGSis the default value fortags; it searches fortagsorTAGSin the current directory and in the directory of the current file.