How I can make `ctrl + click` to go to definition in visual studio code editor for mac OS?
Edit your settings.json
(Hit F1
, type Settings
then Open Default Settings (JSON)
) and adapt your configuration :
Use :
"editor.multiCursorModifier": "alt",
To have Option
+click
as command to go to definition.
Or use :
"editor.multiCursorModifier": "ctrlCmd",
To have Command
+click
as command to go to definition.
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.
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.