How do I rebind keyboard shortcuts in VS Code's terminal?

Viewed 532

I'm running VS Code on macOS and would like to swap the Ctrl and ⌘ keys, but only in the integrated terminal. Is there a way I can do this?

Context: I'm an ex-Windows user now running macOS, and all my muscle memory is based around Ctrl. As such, I've swapped Ctrl and ⌘ in my macOS keyboard settings, which allows me to e.g. copy text as I'd expect using Ctrl+C.

Unfortunately it seems that terminal applications on Mac do actually use the real Ctrl key, e.g. using Ctrl+C to send SIGINT. My global key-swap now makes that ⌘+C, which is icky.

iTerm allows me to swap Ctrl and ⌘ back again, and I'd like to do the same in VS Code - but only in its integrated terminal.

2 Answers

So far my best option has been to rebind individual keystrokes in keybindings.json:

{
    "key": "cmd+c",
    "command": "workbench.action.terminal.sendSequence",
    "args": {
        "text": "\u0003"
    },
    "when": "terminalFocus && !terminalTextSelected"
}

This works, and the set of control characters I'd have to get through is smaller (I'd guess Ctrl + C, Z, D). But this is still not ideal.

If there aren't too many of them it might be easier to change the shortcuts you frequently use (e.g. Cut, Copy, Paste) rather than remap the modifiers.

System Preferences > Keyboard > Shortcuts > App Shortcuts enter image description here

enter image description here

This might make it less confusing to make use of other Mac shortcuts that use Ctrl but maybe this isn't what you are looking for though.

Related