Is there any way to set two keyboard shortcuts for one action in VS code? For example, I want to move the cursor to the left by pressing left arrow key or Alt+A.
-
As far as I know, you need to make a custom macro for both to get that to work.– ifconfigJul 29, 2017 at 0:01
2 Answers
Edit: Starting from 1.52 it's possible from keybindings GUI:
What stops you from editing keybindings.json
?
{
"key": "left",
"command": "cursorLeft",
"when": "textInputFocus"
},
{
"key": "alt+a",
"command": "cursorLeft"
}
It can be opened from Command Palette Preferences: Open Keyboard Shortcuts (JSON)
Or by clicking the file icon from keybindings GUI page:
-
It works. To access keybindings.json one can access the settings and click on the link– aless80Jan 10, 2019 at 5:03
-
12it would be kinda helpful if your answer actually mentioned how you add multiple keybindings. The answer is: create multiple entries, one per desired key. But that's not obvious; it could just as easily have been one entry with a delimited list for key. May 1, 2019 at 18:27
Updating the previous answer and adding tiny more details, atleast in the current 2020 version it seems like after changing the keybindings (atleasy cursor up & down), VSCode creates an entry in the JSON file that can be accessed from Alex's answer. The JSON will contain the new entry you made but also the changed entry with a '-' negative sign on the key instruction. Just remove the '-' negative sign and both your keybindings should work like a charm! Obviously don't forget to save!
-
In version 1.53.2 there is no such json file, nor does the Keyboard Shortcuts GUI have any link above the 'Type to search in keybindings' text entry :(– RazzleJul 24, 2021 at 15:12
-
1That's weird... Don't you see any 'keyboard shortcut JSON' option in the menu tabs? I switched to sublime now so cannot check myself.– YashankJul 24, 2021 at 15:49
-
1+1 for being able to escape from VSCode.. i recently took intellij for a spin and realised how large the chasm is between VSCode and real developer tools..– RazzleJul 27, 2021 at 20:54