I'd like to have Ctrl+C copy and Ctrl+Shift+C send Ctrl+C (interrupt).
I figured out the first half
{
"key": "ctrl+c",
"command": "workbench.action.terminal.copySelection",
"when": "terminalFocus"
}
But how do I do the second half? Is there a command to send an arbitrary key press to the terminal?
Copy & paste# Linux: Ctrl+Shift+C and Ctrl+Shift+V; selection paste is available with Shift+Insert. macOS: Cmd+C and Cmd+V. Windows: Ctrl+C and Ctrl+V.
Click on Site Settings. Click View permissions and data stored across sites. Select the entry for the site that is associated with your VS Code server. Scroll down until you find a Clipboard permission, and select Allow from the provided dropdown menu to the right of the permission.
Go to File → Preferences → Keyboard Shortcuts or just press Ctrl + k + Ctrl + s.
With Visual Studio Code 1.28.0 there is a command, workbench.action.terminal.sendSequence
, to send arbitrary keypresses to the terminal. See Send text from a keybinding to the terminal.
{
"key": "ctrl+shift+c",
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\u0003"
},
"when": "terminalFocus"
}
Answers above are all good. It took me long time to figure out exactly where to put these snippets. In VSCode go to File | Preferences | Keyboard Shortcuts. Switch to json text view by pressing small icon on top-right: Open Keyboard Shortcuts (JSON) and edit setting file: keybindings.json
Example keybindings.json:
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+c",
"command": "workbench.action.terminal.copySelection",
"when": "terminalFocus"
},
{
"key": "ctrl+v",
"command": "workbench.action.terminal.paste",
"when": "terminalFocus"
},
{
"key": "ctrl+shift+c",
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\u0003"
},
"when": "terminalFocus"
},
]
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