Skip to content

Instantly share code, notes, and snippets.

@mklement0
Last active April 12, 2023 19:32
Show Gist options
  • Save mklement0/d3d76e70b3494818a35865e22826b276 to your computer and use it in GitHub Desktop.
Save mklement0/d3d76e70b3494818a35865e22826b276 to your computer and use it in GitHub Desktop.
Sample keybinding.json file for https://stackoverflow.com/a/75980711/45375
// Content for a Visual Studio Code "keybindings.json" file.
// To open your file for editing, use the command palette's "Preferences: Open Keyboard Shortcuts (JSON)" command.
// CAVEAT: You can copy and paste this file's content as-is to REPLACE your file's existing content
// but in doing so you'll lose any PREEXISTING definitions.
// To preserve any existing definitions, append everything *inside* "[" and "]" below to the *preexisting*
// top-level "[" and "]" enclosure (a JSON array), and be sure to append a "," to the last preexisting object
// inside the array before appending (or place the new objects at the top and append a "," to the second of
// the two new objects).
[
// General definition for all shells *except* PowerShell.
{
"key": "ctrl+k",
"when": "terminalFocus && terminalShellType != 'pwsh'",
// Clear the screen and the scrollback buffer.
// For shells other than PowerShell that is sufficient.
"command": "workbench.action.terminal.clear"
},
// Override for PowerShell, to compensate for the following bugs:
// * https://github.com/PowerShell/PSReadLine/issues/841
// * https://github.com/PowerShell/PowerShell/issues/19479
{
"key": "ctrl+k",
"when": "terminalFocus && terminalShellType == 'pwsh'",
// Send a VT / ANSI escape sequence that clears the screen and
// and the scrollback buffers and resets the cursor position.
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "[Console]::Write(\"$([char] 0x1b)[2J$([char] 0x1b)[3J$([char] 0x1b)[H\")\u000d"
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment