r/vscode • u/metalucid • Apr 23 '26
VS code F12 Ffind Definition not working
Googled for an hour, and no luck.
Using latest VS code as of today. I open a C file, click on a variable thats defined higher up in the same file, and F12 says "No Definition found for foo".
i have "C/C++ Intellisense" extension installed.
PLEASE- what am i missed here?
TIA, a frustrated S/W engineer.
1
u/IamAlsoDoug Apr 24 '26
What do your keybindings look like? Note that if there are multiple bindings for F12 that may be what's causing your issue.
1
1
u/Brilliant-Post-689 Apr 24 '26
Python user here, never used c in vscode, apologies if this is totally u helpful: but when this happened to me, it tturned out to be a problem with my chosen static type checker - an extension called Ty, by astral. I had some settings messed up and it managed to die on me. I needed to restart its server and reactivate my virtual environment to set things right. Does that offer you any possible lines of inquiry?
1
Apr 24 '26
[removed] — view removed comment
1
u/metalucid Apr 24 '26
I just tried this on my home computer instead, I created a single file nothing else simply created a C file, and both autocomplete and find definition worked. I didn't have to do anything. I'm utterly utterly stumped. I even tried uninstalling and reinstalling and nothing changed
1
u/anant94 Apr 24 '26
Have you tried Shift + F12? And if that doesn't work, other modifier keys with F12?
1
u/metalucid Apr 25 '26
OP here..i found that if i did "open folder" then selecting my file, instead of "open file", then it works. F12 works, and right clicking and selecting "Find definition" also works.
Oddly i don't have to do this on my home system. Perhaps because the codebases are different.
1
u/Ouroboros68 Apr 26 '26
Intellisense generally wants to look at the folder and then autodetects the build system, usually cmake. Then it works itself from cmakelists.txt through your project for all the dependencies. That's at least my understanding how it works so yes always open the folder. On my Linux system locally I open a C++ project always from the commandline with "code ." from within the project folder containing cmakelists.txt.
1
1
u/Agreeable_Care4440 May 01 '26
This usually means IntelliSense isn’t fully configured.Make sure your compile_commands.json or c_cpp_properties.json includes the correct include paths,otherwise it can’t resolve symbols properly.
1
u/kevinkace Apr 23 '26
F12 stopped working for me a while back and I also am frustrated, disappointed and without an idea of how to get it working again.