69

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.

Is it possible to add multiple keybindings to a shortcut?

2
  • As far as I know, you need to make a custom macro for both to get that to work.
    – ifconfig
    Commented Jul 29, 2017 at 0:01
  • I have edited your question for the sole purpose of making it more likely to show up in search engines. This is exactly what I was looking for and the below answer is also exactly what I was looking for. But it took me a while of searching for different phrases and scrolling to find this. Commented Dec 4, 2022 at 9:53

2 Answers 2

108

Edit: Starting from 1.52 it's possible from keybindings GUI:

keybindings gui context menu add keybinding


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:

enter image description here

2
  • It works. To access keybindings.json one can access the settings and click on the link
    – aless80
    Commented Jan 10, 2019 at 5:03
  • 14
    it 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. Commented May 1, 2019 at 18:27
10

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!

3
  • 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 :(
    – Razzle
    Commented Jul 24, 2021 at 15:12
  • 1
    That's weird... Don't you see any 'keyboard shortcut JSON' option in the menu tabs? I switched to sublime now so cannot check myself.
    – Yashank
    Commented Jul 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..
    – Razzle
    Commented Jul 27, 2021 at 20:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.