Custom keybindings doesn't work in VS Code REPL

I use Greek characters very frequently in my code. So, for example, instead of entering λ by \lambda followed by the tab key, I press Control-Option-L. (I’m a Mac user, and Mac’s Option key would correspond to Window’s Alt key.)

I define these key bindings in keybindings.json, and they work great in the VS Code editor. However, such defined keybindings do not work in the REPL integrated in VS Code. This makes testing scripts very inconvenient. The scripts defines lots of variables in Greek characters, and when I want to assign different values to them in REPL, I need to type them by \lambda followed by the tab key, which is much slower than typing the key binding.

Has anyone experienced the same issue? Is there a way to make the keybindings defined in keybindings.json work in both the main editor and REPL in VS Code?

You could define an additional binding that sends unicode characters to the terminal, e.g.:

        "key": "cmd+backspace",
        "command": "workbench.action.terminal.sendSequence",
        "when": "terminalFocus",
        "args": {"text":"\u0015"}  // ^u

Then, the binding for the editor should have the when clause "when": "!terminalFocus".

I know this is a bit awkward because you need to define everything twice…

1 Like