sponsor Vim development Vim logo Vim Book Ad

basic Tip #8: Jumping to the declaration of a local/global variable

 tip karma   Rating 81/38, Viewed by 2854 

created:   February 24, 2001 18:00      complexity:   basic
author:   Yegappan      as of Vim:   5.7


'gd' command:
To jump to the declaration of a local variable in a C program,
position the cursor on the name of the variable and use the
gd command.

'gD' command:
To jump to the declaration of a global variable in a C program,
position the cursor on the name of the variable and use the
gD command.

 rate this tip  Life Changing Helpful Unfulfilling 

<<Jumping to the start and end of a code block | Displaying a variable/macro definition >>

Additional Notes

[email protected], February 25, 2001 12:06
This works in java, perl and a number of other languages as well!
[email protected], December 10, 2003 14:02
to jump back use `` (backquote backquote)
[email protected], September 1, 2005 18:13
You can also jump back using ctrl-o or ' ' (single qoute, single quote).
nirnimesh-(@)-students.iiit.ac.in, January 30, 2006 6:56
ctags

ctags can be used to do a more comprehensive job.
Make 'tags' file with: ctags -R *.cpp *.h

Then, goto any variable and pressing Ctrl-] will take you to the definition of it's definition. Same for functions as well. Use Ctrl-t to return back.
[email protected], February 3, 2006 10:45
You can also use cscope for this. http://cscope.sourceforge.net/
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
    stats
Sponsored by Web Concept Group Inc. SourceForge.net Logo