How do I quickly see where a keyword was first defined or used without jumping there?
Answer
[i
Explanation
Pressing [i in normal mode displays the first line above the cursor (including included files) that contains the keyword under the cursor. The match is shown in the status line without moving the cursor, making it a zero-friction way to peek at a variable's type, function signature, or macro definition.
How it works
Vim's [{char} family of commands searches upward from the cursor through the current file and any files pulled in via #include (or path-based includes). i stands for the "include" search:
[i— display the first matching line above the cursor[I— list all matching lines above the cursor with line numbers[<C-i>— jump to the first match above the cursor]i— same as[ibut searches downward
The search uses the same keyword definition as * (respecting iskeyword), so it matches whole words only.
Example
With the cursor on MAX_RETRIES:
1: #define MAX_RETRIES 5
...
47: if (attempts > MAX_RETRIES) { ← cursor here
Pressing [i shows in the status bar:
1: #define MAX_RETRIES 5
Tips
- Use
[Iinstead of[iwhen you want to scan all occurrences: each match is numbered so you can jump to any entry withN[<C-i>. - Works through
#includechains whenpathis configured — useful for reading C/C++ codebases. - Complement with
gd(go to local declaration) andgD(go to global declaration) for quick navigation without LSP.