Ubuntu 20.04,gnome-terminal
I try to make CTRL+B to toggle side bar visibility when terminal is focused. Here is my attempt of configuring:
{
"key": "ctrl+b",
"command": "workbench.action.toggleSidebarVisibility",
"when": "terminalFocus"
}
Unfortunately when I focus on a terminal input pressing CTRL+B has no effect and does not toggle the side bar. What's wrong with the configuration?
What is happening is your keybinding is being sent to the shell, rather than Visual Studio Code. You need to add to the terminal.integrated.commandsToSkipShell array the command you want Visual Studio Code to handle when the matching keybinding is performed and you are focused in an integrated terminal. In this case, the command to toggle the sidebar:
"terminal.integrated.commandsToSkipShell": [
"workbench.action.toggleSidebarVisibility"
]
You shouldn't need to create a custom key binding/modify the existing one to have a new when condition.
This setting has a description of:
A set of command IDs whose keybindings will not be sent to the shell but instead always be handled by VS Code. This allows keybindings that would normally be consumed by the shell to act instead the same as when the terminal is not focused, for example Ctrl+P to launch Quick Open
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With