Find a local declaration
gd
Example
Normal 0 / 1Normal 1 / 1int count;
void example() {
int count;
count = 2;
}Cursor on line 4, column 3int count;
void example() {
int count;
count = 2;
}Cursor on line 1, column 5Search for a local declaration of the cursor word.
No recognized function start · found the global count on line 1
Before & after
int count;
void example() {
int count;
count = 2;
}Cursor on line 4, column 3int count;
void example() {
int count;
count = 2;
}Cursor on line 1, column 5Start in Normal mode. The opening brace is not in column 1, so gd does not recognize a function start and searches from line 1, finding the global count rather than the nearer local declaration.
Details & Vim help
Example replayed in Vim
Search for a local declaration of the cursor word.
gd searches for the word under the cursor from the start of the current function. Vim identifies a function by an opening brace in column 1. This example puts the brace at the end of a line, so Vim starts at line 1 and finds the global declaration.