Unnikrishnan
Unnikrishnan

Reputation: 3313

How I can make `ctrl + click` to go to definition in visual studio code editor for mac OS?

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.

Upvotes: 116

Views: 215338

Answers (18)

Ruhith Udakara
Ruhith Udakara

Reputation: 2454

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!

Upvotes: 0

Arnav Kohli
Arnav Kohli

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

Upvotes: -1

yakov
yakov

Reputation: 773

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

Upvotes: 0

Neil Marcellini
Neil Marcellini

Reputation: 1

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

Upvotes: 0

Mahesh
Mahesh

Reputation: 159

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

enter image description here

Upvotes: 4

Ronnie Rasouli
Ronnie Rasouli

Reputation: 1

What worked for me is to run:

# go mod vendor

Then I can reach the definitions by clicking alt

Upvotes: -2

vintagexav
vintagexav

Reputation: 2057

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

Upvotes: 1

SAMIR MENDHE
SAMIR MENDHE

Reputation: 9

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.

Upvotes: 0

George
George

Reputation: 630

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.

Upvotes: 1

Vibhor Bhatia
Vibhor Bhatia

Reputation: 19

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.

Upvotes: 0

Shailendra Madda
Shailendra Madda

Reputation: 21531

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!

Upvotes: 14

Kathy
Kathy

Reputation: 419

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.

Upvotes: 0

Hari Kishore
Hari Kishore

Reputation: 2870

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

Upvotes: 1

mwilcox
mwilcox

Reputation: 4132

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.

Upvotes: 5

Dulaj Madusanka
Dulaj Madusanka

Reputation: 428

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

Upvotes: 0

cactuschibre
cactuschibre

Reputation: 2375

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

Upvotes: 119

jpbarbosa
jpbarbosa

Reputation: 571

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.

Upvotes: 46

Mark
Mark

Reputation: 180785

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.

Upvotes: 10

Related Questions