129

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.

Gama11
34.6k9 gold badges92 silver badges107 bronze badges
asked Aug 29, 2018 at 16:02

21 Answers 21

129

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).

eriegz
3864 silver badges11 bronze badges
answered May 7, 2019 at 14:26
Sign up to request clarification or add additional context in comments.

7 Comments

How about our windows Java?
I don't understand how this is accepted answer the question is about how to change cmd+click to go to definition, but this is just changing multiCursorModifier
@Saba because the default trigger for "editor.multiCursorModifier" is also the default trigger for "goToDefinition". Thus changing the trigger for "editor.multiCursorModifier" allows the ctrl+click command to pass to the next available action which is "goToDefinition"
This answer is literally talking about something entirely different than what the question was, yet is upvoted and selected as the best answrer. LOL
No, this is in fact the correct answer but people should learn to read carefully. 'alt' MUST be selected so the ctrl + click is freed up so to speak. Indeed this solved it for me.
|
47

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.

answered Aug 11, 2019 at 2:19

2 Comments

Do you have any link to share that can provide more details?
does this work for bash ?
17

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!

answered Sep 22, 2022 at 9:33

2 Comments

Thank you. It unblocked me on a Windows environment
In Win 11, it (click word) and F12 == go to definition
10

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.

answered Aug 29, 2018 at 19:46

Comments

6

You can go to the settings and type "Source definition" and check this boxes to go to the definition directly

enter image description here

answered Feb 12, 2024 at 13:17

Comments

5

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.

answered May 6, 2022 at 21:06

3 Comments

Only a mad man would do something like that
How did you turn them off? When I click the dropdown it forces me to choose either ctrlCmd or Alt, but no "off" option is present.
This might help: I had accidentally triggered the command "Toggle Multi-Cursor Modifier" through the the command panel and didn't realise that this made Cmd on my mac become a multi-cursor modifier (previously it was only Alt). Triggering the command again fixed the issue.
4

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.multipleDefinitions and change its value from peek to goto

Done :)

answered Feb 16 at 3:00

Comments

1

For me Ctrl ^+click / Cmd ⌘+click was not working, although F12 was.
So, tried with option ⌥+click, which worked.

answered Jul 28, 2022 at 6:54

Comments

1

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.

answered Jan 10, 2023 at 8:56

Comments

1

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 :)

answered May 5, 2023 at 13:07

Comments

0

go to .flowconfig file and change the required the version(it is the bottom)

answered Mar 15, 2022 at 3:00

Comments

0

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.

answered Aug 31, 2022 at 12:32

Comments

0

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.

answered Nov 14, 2022 at 10:45

Comments

0

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.

S.B
17k12 gold badges38 silver badges73 bronze badges
answered Feb 27, 2023 at 17:22

Comments

0

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.

VSCode settings

answered Apr 12, 2024 at 23:22

Comments

0

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

settings vs code

answered May 16, 2024 at 9:24

Comments

0
"C_Cpp.intelliSenseEngine": "disabled" 

change disable to "default" in global settings.json if using C/C++ extension.

answered Feb 18 at 8:09

Comments

0

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 :)

answered Feb 25 at 15:37

Comments

-1

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

answered Oct 17, 2024 at 5:16

Comments

-1

If you’re encountering this issue with your JavaScript projects in VS Code on Ubuntu, try the following steps:

  1. Go to the Extensions panel and select "Disable All Extensions".
  2. Close and reopen VS Code.
  3. Return to the Extensions panel and select "Enable All Extensions".
  4. Restart VS Code.

This resolved my issue, and I hope it helps others working with JS on Ubuntu!

answered Nov 5, 2024 at 7:19

Comments

-2

What worked for me is to run:

# go mod vendor

Then I can reach the definitions by clicking alt

jmoerdyk
5,5428 gold badges42 silver badges58 bronze badges
answered May 18, 2023 at 14:56

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.