3

I'm trying to add a new command for "Control C" on the integrated terminal but for some reason It just work when the terminal is not focused.

Here's the configuration:

 { "key": "shift+backspace", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0003" }, } 

I've also tried to remove the default command for "shift+backspace"

 { "key": "shift+backspace", "command": "-deleteLeft", "when": "textInputFocus && !editorReadonly" } 

Any ideas why it doesn't work?

2 Answers 2

2

The issue is that the integrated terminal "consumes" many keystrokes (like ctrl-c) preventing them from being used for keybindings since they are never passed to VScode when the integrated terminal has focus.

Basically, bind the key(s) you want to the desired command, like (in keybindings.json or using the keyboard short cut editor)

... { "key": "ctrl-x o", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus" }, ... 

Then add the COMMAND (workbench.action.focusActiveEditorGroup here) to the setting Commands To Skip Shell. In this example, ctrl-x would not be passed to the terminal after this. (What does ctrl-x do, anyway? ) Note that this can remove the ability to send signals to the integrated terminal.

See the setting Terminal › Integrated: Commands To Skip Shell and the documentation at https://code.visualstudio.com/docs/editor/integrated-terminal#_forcing-key-bindings-to-pass-through-the-terminal for more information.

Sign up to request clarification or add additional context in comments.

Comments

1

Some keychords seem to be consumed by vscode and never get to the terminal. I haven't been able to figure out which ones. I couldn't get Shift-backspace to work either, but other keychords do such as the following:

{ "key": "ctrl+shift+c", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0003" }, } 

Perhaps you are ultimately trying to do something like terminate a process with a keybinding?

4 Comments

Actually not, I'm a mac user(it doesn't have a ctrl key on right side) and I'm trying to get a key combination that I can use with my right hand for the Ctrl+C command on Vs code integrated terminal because I want to reduce amount commands I use with left hand. Funny thing is, I've manage to use "alt+s" for "Ctrl + R" and "shift + =" for "Ctrl+C"
I'm sure there are other keychords that will work - I don't have a mac keyboard to look at. No command key on the right side?
There's command key on right side but not ctrl key. For terminal commands such as Ctrl+C, Ctrl+R, etc, it's the "original" Ctrl key.
I've decided to use with shift + = it's similar to shift+backspace, thanks anyway.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.