How I can make ctrl + click to go to definition in visual studio code editor for mac OS? Now it is F12 which is using my mac for show desktop.
21 Answers 21
First and foremost, please note that in VS Code for macOS, the familiar Ctrl + click from Windows / Linux operating systems has been replaced with ⌘ + click (i.e.: "command + click"). Try that first before proceeding any further as that shortcut should work out of the box without any special modifications.
However, if the above still doesn't work for you then try fixing the problem by editing your settings.json file. To do that, press F1, type settings json, then click Open Settings (JSON), and then do one of the following:
To use ⌘ + click as your "Go to definition" shortcut, ensure the following line exists in your JSON settings:
"editor.multiCursorModifier": "alt",
What this does is it explicitly sets VS Code's "add another cursor" shortcut to option + click (try it out for yourself!), thus freeing up ⌘ + click to be used for the "Go to definition" operation.
Conversely, to use option + click as your "Go to definition" shortcut instead, add:
"editor.multiCursorModifier": "ctrlCmd",
Note: the above line will actually set the "add another cursor" shortcut to ⌘ + click (not Ctrl + ⌘ + click, as implied by the JSON value).
7 Comments
Settings> User> multiCursorModifier must be set to alt (default), so the ctrl/cmd will be available to go to definition.
Documentation:
The modifier to be used to add multiple cursors with the mouse. The Go To Definition and Open Link mouse gestures will adapt such that they do not conflict with the multicursor modifier.
2 Comments
In my case, I checked this in the settings
Settings > User > multiCursorModifier must be set to alt (default)
By default, it is set to alt only
I just did right-click on VS code and quit and open it again to resolve the issue.
Hope it may help someone!
2 Comments
In gear icon/keyboard shortcuts, search for f12 .
Right-click on the "Go to Definition" entry and chose "Remove Keybinding".
Note that will put a new entry at the end of your keybindings.json like:
{
"key": "f12",
"command": "-editor.action.goToDeclaration",
"when": "editorHasDefinitionProvider && editorTextFocus && !isInEmbeddedEditor"
}
Note the "-" sign before the command, that removes that keybinding. Now copy and paste that whole entry below it (with a comma at the end of the previous entry):
{
"key": "f12",
"command": "-editor.action.goToDeclaration",
"when": "editorHasDefinitionProvider && editorTextFocus && !isInEmbeddedEditor"
},
{
"key": "cmd+enter",
"command": "editor.action.goToDeclaration",
"when": "editorHasDefinitionProvider && editorTextFocus && !isInEmbeddedEditor"
}
Remove the minus sign and assign whatever keybinding you like. Alternatively, go back to shortcuts file, search for "Go to Definiton" and click the pencil icon to use its interface to create a new keybinding.
Note that Ctrl-Enter is used in many contexts so you might have an unexpected conflict using such a common keybinding.
Comments
You can go to the settings and type "Source definition" and check this boxes to go to the definition directly
Comments
I found what turned off this feature.
Go to Settings and search for "ctrlCmd". There are two settings that overrode the command: Editor: Multi Cursor Modifier and List: Multi Select Modifier. I turned both of these off because I don't use them, and I got my control-click to definition back.
I know those settings are useful to some. The default for both is alt-click. I presume an extension or an update changed something.
3 Comments
Cmd on my mac become a multi-cursor modifier (previously it was only Alt). Triggering the command again fixed the issue.For anyone in 2025, here is a solution for this:
- Open settings (Ctrl+, in Windows or simply open command palette and search settings)
- Search for
editor.gotoLocation.multipleDefinitionsand change its value frompeektogoto
Done :)
Comments
For me Ctrl ^+click / Cmd ⌘+click was not working, although F12 was.
So, tried with option ⌥+click, which worked.
Comments
In my case cmd+click wasn't working when i was connected to a remote machine via remote ssh, but worked fine locally. Installing language extensions(C/C++ Extension Pack in my case) on a remote solved the issue for me.
Comments
What worked for me was, on MacOs, was to click on "disable all extensions" in Visual Studio code, then restart the app, then click on "enable all extensions" again, and open another workspace :)
Comments
go to .flowconfig file and change the required the version(it is the bottom)
Comments
In my vscode, this problem is proved to be caused by some extensions. After removing one extension(I forget the name, should be related with vscode), it works.
Comments
I was facing similar issue with my python code though it was working fine with my JS code. I have to install Python extension developed by Microsoft & it worked.
Comments
Go to visual studio code -> Click on extension(left of screen) -> update your language extension.
Eg. If you are using python, then install updated python extension there.
Comments
This may be slightly tangential, but my problem was that in C++ I want command+click to always take me to the declaration or definition if I'm not there already.
The way I fixed this was to search user settings for "go to definition". Then I set the "Alternative Declaration Command" as go to implementation and the "Alternative Definition Command" as reveal declaration, which seems to work the same a "go to" in that it navigates you there.
Comments
For me, the solution was to disable the Alt Click Moves Cursor in the checkbox.
or add this line to setting JSON
"terminal.integrated.altClickMovesCursor": false
Comments
"C_Cpp.intelliSenseEngine": "disabled"
change disable to "default" in global settings.json if using C/C++ extension.
Comments
just in case you too were facing this issue on an HPC/ssh system, you need to separately install the Python extension for the ssh on VS code :)
Comments
The issue in my case was the VS Code was not up to date, as it was in the Downloads folder instead of Applications. So just move it to Applications and Update your VS Code and it should work.
P.S - If it is still not working, try uninstalling and installing all extensions
Comments
If you’re encountering this issue with your JavaScript projects in VS Code on Ubuntu, try the following steps:
- Go to the Extensions panel and select "Disable All Extensions".
- Close and reopen VS Code.
- Return to the Extensions panel and select "Enable All Extensions".
- Restart VS Code.
This resolved my issue, and I hope it helps others working with JS on Ubuntu!
Comments
What worked for me is to run:
# go mod vendor
Then I can reach the definitions by clicking alt