Skip to content

Commit

Permalink
Fix VSCode integrated terminal forward delete word
Browse files Browse the repository at this point in the history
In VSCode 1.62.2, alt+delete (forward delete or forward kill word) began
behaving like the enter key, sending commands instead of deleting words.
This was occurring with both Bash and Zsh.

Diagnostics:

- Command Palette -> Enable escape sequence logging
- Command Palette -> Toggle developer tools
- Open the developer tools console
- Start typing commands into the terminal

Solution:

Add a keybinding to trigger `workbench.action.terminal.sendSequence`
with `\u001bd` when `alt+delete` key events occur.

`\u001bd` is a JavaScript Unicode escape sequence:

- `\u` demarcates the sequence
- `001b` is the escape sequence
- `d` is an additional modifier

VSCode recognizes `\u001bd` as `alt+d`, which is forward delete.

microsoft/vscode#95802
https://github.com/microsoft/vscode/blob/1.62.2/src/vs/workbench/contrib/terminal/browser/terminal.contribution.ts#L167-L171
https://code.visualstudio.com/docs/editor/integrated-terminal
https://github.com/microsoft/vscode/wiki/Terminal-Issues
https://mathiasbynens.be/notes/javascript-escapes
  • Loading branch information
br3ndonland committed Nov 17, 2021
1 parent 18bba00 commit a71fdc7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions vscode/User/keybindings.json
Expand Up @@ -65,6 +65,13 @@
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
},
// Fix terminal forward delete word
{
"key": "alt+delete",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u001bd" },
"when": "terminalFocus"
},
// Go to definition
{
"key": "ctrl+cmd+g",
Expand Down

0 comments on commit a71fdc7

Please sign in to comment.