F12 can't go to definition

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When I use cursor for my C++ project, I just can’t use the F12 ,it won’t work. By the way ,I use ctrl + shfit + i to format my code, but in cursor the shorcut was tied with new agent windows.These questions have been puzzling me for a long time.
thank you for your time

Steps to Reproduce

in any odrdinary c++project

Operating System

Linux

Version Information

Version: 3.7.21
VS Code Extension API: 1.105.1
Commit: 517f696d8ab6c53eb04fbfdaae705cd146bf3460
Date: 2026-06-07T21:46:09.237Z
Layout: editor
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
xterm.js: 6.1.0-beta.256
OS: Linux x64 7.0.0-15-generic

Does this stop you from using Cursor

Yes - Cursor is unusable

Hey, thanks for the report. There are two separate things here, and neither is a bug. Let’s go step by step.

  1. F12 and go-to-definition in C++

Go-to-definition works through the language server for each language, not through Cursor core. For C++ you need to install a C/C++ extension and set up IntelliSense.

  • Open a .cpp or .h file and Cursor will prompt you to install the C/C++ extension anysphere.cpptools. Or install clangd with llvm-vs-code-extensions.vscode-clangd.
  • For symbols to resolve, IntelliSense needs a compile_commands.json or a configured includePath and compiler. Without that, F12 and Ctrl+click won’t do anything.

After you install and configure it, go-to-definition should work.

  1. Ctrl+Shift+I opens the agent window instead of formatting

This is by design. On Linux, Cursor binds New Agent to Ctrl+Shift+I, and that intentionally overrides the default Format Document shortcut.

You can format code like this:

  • Shift+Alt+F (cross-platform formatting shortcut)
  • Right-click and select Format Document
  • Or rebind it: open Keyboard Shortcuts, find editor.action.formatDocument, and assign Ctrl+Shift+I, or remove the New Agent binding from that shortcut.

Let me know if F12 still doesn’t work after installing the C/C++ extension.

Thank you for you detailed replay

I’ll add some supplementary information. First I already install clang in my cursor,and my C++ project setting.json as below:

{


“C_Cpp.intelliSenseEngine”: “disabled”,

“C_Cpp.enhancedColorization”: “disabled”,

“C_Cpp.autocomplete”: “Disabled”,

“C_Cpp.errorSquiggles”: “disabled”,

“clangd.arguments”: [

“–compile-commands-dir=${workspaceFolder}/build”,

“–background-index”,

“-j=12”,

“–all-scopes-completion”,

“–completion-style=detailed”,

“–header-insertion=never”,

“–pch-storage=memory”,

“–index-file=/tmp/clangd-index”

\],

“editor.formatOnSave”: true,

“[cpp]”: {

“editor.defaultFormatter”: “llvm-vs-code-extensions.vscode-clangd”,

“editor.formatOnSaveTimeout”: 3000

},

“[c]”: {

“editor.defaultFormatter”: “llvm-vs-code-extensions.vscode-clangd”,

“editor.formatOnSaveTimeout”: 3000

},

“remote.autoForwardPortsSource”: “hybrid”,

“workbench.activityBar.orientation”: “vertical”,

“clangd.path”: “/home/layla/.config/Cursor/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/22.1.0/clangd_22.1.0/bin/clangd”

}

Thanks for the extra info. Your config looks almost right. cpptools IntelliSense is disabled, which is what you want when using clangd. Since clangd is installed but F12 still does nothing, the issue is almost certainly with the clangd index, not Cursor itself. Let’s check it step by step.

  1. The key thing is compile_commands.json. You have --compile-commands-dir=${workspaceFolder}/build, so clangd looks for the file specifically in build/. Please verify it’s really there and not empty:

    • For CMake, build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON so the file is generated in the build directory.
    • Or generate it with bear -- make.
      Without a valid compile_commands.json, clangd can’t resolve includes and symbols, so F12 and Ctrl+click just won’t do anything.
  2. Check the clangd logs: Ctrl+Shift+U to open the Output panel, then pick clangd in the dropdown. You’ll see whether it found compile_commands.json and what indexing errors it hit. This is the fastest way to spot what’s blocking it.

  3. After the file is in place, restart the language server: Ctrl+Shift+P then clangd: Restart language server, and give it time to finish indexing the project. On big codebases it can take a while, especially with --background-index.

Can you paste what the clangd Output panel shows when you open a .cpp file? That should make it clear where it’s failing.