Ctrl-backspace does not delete back to the previous wordbreak #1034

Closed
opened 2026-01-30 22:14:19 +00:00 by claunia · 74 comments
Owner

Originally created by @DHowett-MSFT on GitHub (May 13, 2019).

It deletes character-by-character instead.

Originally created by @DHowett-MSFT on GitHub (May 13, 2019). It deletes character-by-character instead.
Author
Owner

@Kapperchino commented on GitHub (May 13, 2019):

I don't see the keybinding in the terminal app, it might not be implemented.

@Kapperchino commented on GitHub (May 13, 2019): I don't see the keybinding in the terminal app, it might not be implemented.
Author
Owner

@DHowett-MSFT commented on GitHub (May 14, 2019):

@kapperchino More to the point, though, is that Ctrl+Backspace is a VT sequence that needs to be serialized and sent to the application on the other end... it's not likely to be rebindable or otherwise treated as a key binding.

@DHowett-MSFT commented on GitHub (May 14, 2019): @kapperchino More to the point, though, is that Ctrl+Backspace is a VT sequence that needs to be serialized and sent to the application on the other end... it's not likely to be rebindable or otherwise treated as a key binding.
Author
Owner

@vapier commented on GitHub (May 14, 2019):

you just want to make sure the right sequence is sent to the foreground program in the terminal right? the job of deleting words is handled by the shell rather than the terminal since the terminal has no concept of words, only cells.

@vapier commented on GitHub (May 14, 2019): you just want to make sure the right sequence is sent to the foreground program in the terminal right? the job of deleting words is handled by the shell rather than the terminal since the terminal has no concept of words, only cells.
Author
Owner

@DHowett-MSFT commented on GitHub (May 14, 2019):

Yes.


From: Mike Frysinger notifications@github.com
Sent: Tuesday, May 14, 2019 2:19:01 PM
To: microsoft/Terminal
Cc: Dustin Howett; Author
Subject: Re: [microsoft/Terminal] Ctrl-backspace does not delete back to the previous wordbreak (#755)

you just want to make sure the right sequence is sent to the foreground program in the terminal right? the job of deleting words is handled by the shell rather than the terminal since the terminal has no concept of words, only cells.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTerminal%2Fissues%2F755%3Femail_source%3Dnotifications%26email_token%3DADNHLGSJTE4KKXWHDECROFDPVMUELA5CNFSM4HMTV4DKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVM2FPI%23issuecomment-492413629&data=01%7C01%7Cduhowett%40microsoft.com%7C1997e6ff518e4a3f396708d6d8b1c987%7C72f988bf86f141af91ab2d7cd011db47%7C1&sdata=V1y3C26WGNZ50VnZW5BhV1CYKetf%2BgGLqov9Sc9tLw0%3D&reserved=0, or mute the threadhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FADNHLGQKRNJQTZBZCRAZMO3PVMUELANCNFSM4HMTV4DA&data=01%7C01%7Cduhowett%40microsoft.com%7C1997e6ff518e4a3f396708d6d8b1c987%7C72f988bf86f141af91ab2d7cd011db47%7C1&sdata=auF20gJCIvXV%2FYpDN0e%2B3JzvxI766ZTbszhk3qx%2BwUo%3D&reserved=0.

@DHowett-MSFT commented on GitHub (May 14, 2019): Yes. ________________________________ From: Mike Frysinger <notifications@github.com> Sent: Tuesday, May 14, 2019 2:19:01 PM To: microsoft/Terminal Cc: Dustin Howett; Author Subject: Re: [microsoft/Terminal] Ctrl-backspace does not delete back to the previous wordbreak (#755) you just want to make sure the right sequence is sent to the foreground program in the terminal right? the job of deleting words is handled by the shell rather than the terminal since the terminal has no concept of words, only cells. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTerminal%2Fissues%2F755%3Femail_source%3Dnotifications%26email_token%3DADNHLGSJTE4KKXWHDECROFDPVMUELA5CNFSM4HMTV4DKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVM2FPI%23issuecomment-492413629&data=01%7C01%7Cduhowett%40microsoft.com%7C1997e6ff518e4a3f396708d6d8b1c987%7C72f988bf86f141af91ab2d7cd011db47%7C1&sdata=V1y3C26WGNZ50VnZW5BhV1CYKetf%2BgGLqov9Sc9tLw0%3D&reserved=0>, or mute the thread<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FADNHLGQKRNJQTZBZCRAZMO3PVMUELANCNFSM4HMTV4DA&data=01%7C01%7Cduhowett%40microsoft.com%7C1997e6ff518e4a3f396708d6d8b1c987%7C72f988bf86f141af91ab2d7cd011db47%7C1&sdata=auF20gJCIvXV%2FYpDN0e%2B3JzvxI766ZTbszhk3qx%2BwUo%3D&reserved=0>.
Author
Owner

@Summon528 commented on GitHub (Jun 3, 2019):

FYI, if you launch PowerShell through WSL, ctrl + backspace will also delete character-by-character, so this is probably not Terminal's problem.

@Summon528 commented on GitHub (Jun 3, 2019): FYI, if you launch PowerShell through WSL, `ctrl + backspace` will also delete character-by-character, so this is probably not Terminal's problem.
Author
Owner

@Summon528 commented on GitHub (Jun 3, 2019):

Apparently Ctrl + backspace == <U+0008> == ^H which most shells including PowerShell treated as delete one char, so this is kind of by design? Also, this is probably why most Linux shells use Alt + backspace instead

@Summon528 commented on GitHub (Jun 3, 2019): Apparently `Ctrl + backspace == <U+0008> == ^H` which most shells including PowerShell treated as delete one char, so this is kind of by design? Also, this is probably why most Linux shells use `Alt + backspace` instead
Author
Owner

@zadjii-msft commented on GitHub (Jun 3, 2019):

Yea this might be a PSReadline thing TBH. I bet they're looking for an INPUT_RECORD with ctrl+backspace, but as @Summon528 mentioned, we're sending ^H, which is what most terminal emulators will send for ctrl+backspace.

Then, when conpty recieves the ^H, it will translate that to:
image

as opposed to
image

This might be solvable with the whole conpty INPUT_RECORD thing

@zadjii-msft commented on GitHub (Jun 3, 2019): Yea this might be a PSReadline thing TBH. I bet they're looking for an `INPUT_RECORD` with ctrl+backspace, but as @Summon528 mentioned, we're sending `^H`, which is what most terminal emulators will send for ctrl+backspace. Then, when conpty recieves the `^H`, it will translate that to: ![image](https://user-images.githubusercontent.com/18356694/58810244-28cb6700-85e3-11e9-8698-dc2ce7248c6c.png) as opposed to ![image](https://user-images.githubusercontent.com/18356694/58810334-57e1d880-85e3-11e9-93b1-5d2c2a8a7fe1.png) This might be solvable with the whole conpty INPUT_RECORD thing
Author
Owner

@gohar94 commented on GitHub (Jun 24, 2019):

Regular PowerShell does delete back till previous wordbreak so I'd expect the PowerShell tabs in Windows Terminal to do the same.

@gohar94 commented on GitHub (Jun 24, 2019): Regular PowerShell does delete back till previous wordbreak so I'd expect the PowerShell tabs in Windows Terminal to do the same.
Author
Owner

@DHowett-MSFT commented on GitHub (Jun 24, 2019):

"I'd expect"

good, that's why this is a bug that's still open and not resolved as By Design

@DHowett-MSFT commented on GitHub (Jun 24, 2019): > "I'd expect" good, that's why this is a bug that's still open and not resolved as By Design
Author
Owner

@rkeithhill commented on GitHub (Jun 26, 2019):

@lzybkr @daxian-dbw Any thoughts on this? It is a bummer that ctrl+backspace doesn't work when PS Core runs in Windows Terminal. FWIW this is also an issue with cmd.exe.

@rkeithhill commented on GitHub (Jun 26, 2019): @lzybkr @daxian-dbw Any thoughts on this? It is a bummer that `ctrl+backspace` doesn't work when PS Core runs in Windows Terminal. FWIW this is also an issue with cmd.exe.
Author
Owner

@lzybkr commented on GitHub (Jun 26, 2019):

I don't have a solution, but on Windows, PSReadLine relies on the CLR to map INPUT_RECORDs with more precision than what you typically get with non-Windows terminals. There is also a related platform specific assumption being made here:

f2f5531560/PSReadLine/Keys.cs (L291)

@lzybkr commented on GitHub (Jun 26, 2019): I don't have a solution, but on Windows, PSReadLine relies on the CLR to map INPUT_RECORDs with more precision than what you typically get with non-Windows terminals. There is also a related platform specific assumption being made here: https://github.com/PowerShell/PSReadLine/blob/f2f553156063a8635b9d4882a878a828365cdd99/PSReadLine/Keys.cs#L291
Author
Owner

@richardszalay commented on GitHub (Jul 18, 2019):

FWIW, you can workaround this problem by press CTRL+SHIFT+LEFT (which selects the previous word) and then pressing backspace. It's far from ideal, but it's more efficient than backspaces through the individual characters.

@richardszalay commented on GitHub (Jul 18, 2019): FWIW, you can workaround this problem by press CTRL+SHIFT+LEFT (which selects the previous word) and then pressing backspace. It's far from ideal, but it's more efficient than backspaces through the individual characters.
Author
Owner

@JakeShirley commented on GitHub (Aug 9, 2019):

I'd also love to see this fixed! Definitely a jarring change from using regular PowerShell.

@JakeShirley commented on GitHub (Aug 9, 2019): I'd also love to see this fixed! Definitely a jarring change from using regular PowerShell.
Author
Owner

@awhewell commented on GitHub (Aug 24, 2019):

Just to be clear, this is not only an issue with powershell tabs. I originally came here to report it not working on cmd.exe tabs.

Moreover the CTRL+SHIFT+LEFT workaround does not work in cmd.exe tabs. If you type "foo" and then CTRL+SHIFT_LEFT then it just moves the cursor to the start of "foo". It does not select the word so pressing backspace does not then have the desired effect.

@awhewell commented on GitHub (Aug 24, 2019): Just to be clear, this is not only an issue with powershell tabs. I originally came here to report it not working on cmd.exe tabs. Moreover the CTRL+SHIFT+LEFT workaround does not work in cmd.exe tabs. If you type "foo" and then CTRL+SHIFT_LEFT then it just moves the cursor to the start of "foo". It does not select the word so pressing backspace does not then have the desired effect.
Author
Owner

@williamclot commented on GitHub (Sep 12, 2019):

I'm using zsh as my shell in WSL. When using bindkey '^H' backward-kill-word I get the expected behavior.

This is my configuration:

bindkey -e
# Control + backspace
bindkey '^H' backward-kill-word
# Control + arrows
bindkey ";5C" forward-word
bindkey ";5D" backward-word
@williamclot commented on GitHub (Sep 12, 2019): I'm using zsh as my shell in WSL. When using `bindkey '^H' backward-kill-word` I get the expected behavior. This is my configuration: ```bash bindkey -e # Control + backspace bindkey '^H' backward-kill-word # Control + arrows bindkey ";5C" forward-word bindkey ";5D" backward-word ```
Author
Owner

@yggdrasil75 commented on GitHub (Sep 25, 2019):

I would like to note on this issue that almost every program by microsoft, as well as most external programs use control+backspace to delete the entire word, however it is not for some reason a native windows function, which means that each of those programs either have to manually add support for the functionality, or their compiler does it for them. This is such a standard function that it is expected to occur everywhere by people who know hotkeys, would it not be more prudent to add it as a native windows function than to just update the various terminals?

(side note: explorer.exe also inserts ascii 127 - delete character instead of deleting the entire word)

@yggdrasil75 commented on GitHub (Sep 25, 2019): I would like to note on this issue that almost every program by microsoft, as well as most external programs use control+backspace to delete the entire word, however it is not for some reason a native windows function, which means that each of those programs either have to manually add support for the functionality, or their compiler does it for them. This is such a standard function that it is expected to occur everywhere by people who know hotkeys, would it not be more prudent to add it as a native windows function than to just update the various terminals? (side note: explorer.exe also inserts ascii 127 - delete character instead of deleting the entire word)
Author
Owner

@jnm2 commented on GitHub (Sep 25, 2019):

Some history on Ctrl+Backspace: https://devblogs.microsoft.com/oldnewthing/?p=24823

@jnm2 commented on GitHub (Sep 25, 2019): Some history on Ctrl+Backspace: https://devblogs.microsoft.com/oldnewthing/?p=24823
Author
Owner

@jevring commented on GitHub (Oct 11, 2019):

Use bind '"\C-H":backward-kill-word' in bash to solve this issue.

@jevring commented on GitHub (Oct 11, 2019): Use `bind '"\C-H":backward-kill-word'` in bash to solve this issue.
Author
Owner

@Geogboe commented on GitHub (Oct 17, 2019):

Definitely agree @yggdrasil75 that pretty every text editor/browser supports this, along with cmd.exe and powershell.exe and even notepad in the latest windows builds.

This is a big blocker for me, especially since I use powershell and powershell cmdlets/params can get long. Having to use basic backspace or select previous word and then backspace just breaks up my workflow too much.

For anyone else who is using autohotkey I just wanted to throw out that this simple macro will allow you to workaround this until it's implemented.

#SingleInstance force ; Automatically overwrite any running instance of this script
#Persistent ; If this directive is present anywhere in the script, that script will stay running after the auto-execute section (top part of the script) completes

; For Windows Terminal - deletes the previous word
#IfWinActive ahk_exe WindowsTerminal.exe ; Wait for WindowsTerminal to be active
^backspace::
    Send, ^+{Left}
    Send, {Delete}
return

It sucks having something like this always running but I'm only going this route because of how much I love all other aspects of terminal and this is the final piece that makes this the perfect terminal for me.

@Geogboe commented on GitHub (Oct 17, 2019): Definitely agree @yggdrasil75 that pretty every text editor/browser supports this, along with cmd.exe and powershell.exe and even notepad in the latest windows builds. This is a big blocker for me, especially since I use powershell and powershell cmdlets/params can get long. Having to use basic backspace or select previous word and then backspace just breaks up my workflow too much. For anyone else who is using autohotkey I just wanted to throw out that this simple macro will allow you to workaround this until it's implemented. ```ahk #SingleInstance force ; Automatically overwrite any running instance of this script #Persistent ; If this directive is present anywhere in the script, that script will stay running after the auto-execute section (top part of the script) completes ; For Windows Terminal - deletes the previous word #IfWinActive ahk_exe WindowsTerminal.exe ; Wait for WindowsTerminal to be active ^backspace:: Send, ^+{Left} Send, {Delete} return ``` It sucks having something like this always running but I'm only going this route because of how much I love all other aspects of terminal and this is the final piece that makes this the perfect terminal for me.
Author
Owner

@paulelms commented on GitHub (Oct 25, 2019):

Fix for PSReadLine:
Set-PSReadLineKeyHandler -Key Ctrl+h -Function BackwardKillWord

@paulelms commented on GitHub (Oct 25, 2019): Fix for [PSReadLine](https://github.com/PowerShell/PSReadLine): `Set-PSReadLineKeyHandler -Key Ctrl+h -Function BackwardKillWord`
Author
Owner

@decoyjoe commented on GitHub (Oct 25, 2019):

Definitely agree @yggdrasil75 that pretty every text editor/browser supports this, along with cmd.exe and powershell.exe and even notepad in the latest windows builds.

This is a big blocker for me, especially since I use powershell and powershell cmdlets/params can get long. Having to use basic backspace or select previous word and then backspace just breaks up my workflow too much.

For anyone else who is using autohotkey I just wanted to throw out that this simple macro will allow you to workaround this until it's implemented.

#SingleInstance force ; Automatically overwrite any running instance of this script
#Persistent ; If this directive is present anywhere in the script, that script will stay running after the auto-execute section (top part of the script) completes

; For Windows Terminal - deletes the previous word
#IfWinActive ahk_exe WindowsTerminal.exe ; Wait for WindowsTerminal to be active
^backspace::
    Send, ^+{Left}
    Send, {Delete}
return

It sucks having something like this always running but I'm only going this route because of how much I love all other aspects of terminal and this is the final piece that makes this the perfect terminal for me.

Be sure to turn off context sensitivity with #IfWinActive directly after this if you use any other hotkeys in your AHK script, otherwise any hotkeys defined below it will only apply when ahk_exe WindowsTerminal.exe is active.

; For Windows Terminal - deletes the previous word
#IfWinActive ahk_exe WindowsTerminal.exe ; only apply to this active window
^backspace::
    Send, ^+{Left}
    Send, {Delete}
return
#IfWinActive ; turns off context sensitivity
@decoyjoe commented on GitHub (Oct 25, 2019): > Definitely agree @yggdrasil75 that pretty every text editor/browser supports this, along with cmd.exe and powershell.exe and even notepad in the latest windows builds. > > This is a big blocker for me, especially since I use powershell and powershell cmdlets/params can get long. Having to use basic backspace or select previous word and then backspace just breaks up my workflow too much. > > For anyone else who is using autohotkey I just wanted to throw out that this simple macro will allow you to workaround this until it's implemented. > > ```ahk > #SingleInstance force ; Automatically overwrite any running instance of this script > #Persistent ; If this directive is present anywhere in the script, that script will stay running after the auto-execute section (top part of the script) completes > > ; For Windows Terminal - deletes the previous word > #IfWinActive ahk_exe WindowsTerminal.exe ; Wait for WindowsTerminal to be active > ^backspace:: > Send, ^+{Left} > Send, {Delete} > return > ``` > > It sucks having something like this always running but I'm only going this route because of how much I love all other aspects of terminal and this is the final piece that makes this the perfect terminal for me. Be sure to turn off context sensitivity with `#IfWinActive` directly after this if you use any other hotkeys in your AHK script, otherwise any hotkeys defined below it will only apply when `ahk_exe WindowsTerminal.exe` is active. ``` ; For Windows Terminal - deletes the previous word #IfWinActive ahk_exe WindowsTerminal.exe ; only apply to this active window ^backspace:: Send, ^+{Left} Send, {Delete} return #IfWinActive ; turns off context sensitivity ```
Author
Owner

@CindyKee commented on GitHub (Oct 25, 2019):

Fix for PSReadLine:
Set-PSReadLineKeyHandler -Key Ctrl+h -Function BackwardKillWord

Thank you so much for this, @paulelms ! It works great in my PowerShell/Core windows, which I use the most! Awesome!🥇

@CindyKee commented on GitHub (Oct 25, 2019): > Fix for [PSReadLine](https://github.com/PowerShell/PSReadLine): > `Set-PSReadLineKeyHandler -Key Ctrl+h -Function BackwardKillWord` Thank you so much for this, @paulelms ! It works great in my PowerShell/Core windows, which I use the most! Awesome!🥇
Author
Owner

@TylerLeonhardt commented on GitHub (Oct 31, 2019):

We had to do something similar for vscode's terminal.

if ($env:TERM_PROGRAM -eq "vscode") {
    Set-PSReadLineKeyHandler -Chord 'Ctrl+w' -Function BackwardKillWord
    Set-PSReadLineKeyHandler -Chord 'Alt+D' -Function KillWord
    Set-PSReadLineKeyHandler -Chord 'Ctrl+@' -Function MenuComplete    
}

Ctrl+Backspace gave us Ctrl+w
Ctrl+Spacebar gave us Ctrl+@

I actually added these as default keybindings in PSReadLine since vscode was such a common scenario.

Perhaps some alignment with them (aka xterm.js) is worth it for everyone?

@TylerLeonhardt commented on GitHub (Oct 31, 2019): We had to do something similar for vscode's terminal. ``` if ($env:TERM_PROGRAM -eq "vscode") { Set-PSReadLineKeyHandler -Chord 'Ctrl+w' -Function BackwardKillWord Set-PSReadLineKeyHandler -Chord 'Alt+D' -Function KillWord Set-PSReadLineKeyHandler -Chord 'Ctrl+@' -Function MenuComplete } ``` Ctrl+Backspace gave us Ctrl+w Ctrl+Spacebar gave us Ctrl+@ I actually added these as default keybindings in PSReadLine since vscode was such a common scenario. Perhaps some alignment with them (aka xterm.js) is worth it for everyone?
Author
Owner

@Kralizek commented on GitHub (Nov 12, 2019):

We had to do something similar for vscode's terminal.

if ($env:TERM_PROGRAM -eq "vscode") {
    Set-PSReadLineKeyHandler -Chord 'Ctrl+w' -Function BackwardKillWord
    Set-PSReadLineKeyHandler -Chord 'Alt+D' -Function KillWord
    Set-PSReadLineKeyHandler -Chord 'Ctrl+@' -Function MenuComplete    
}

Ctrl+Backspace gave us Ctrl+w
Ctrl+Spacebar gave us Ctrl+@

I actually added these as default keybindings in PSReadLine since vscode was such a common scenario.

Perhaps some alignment with them (aka xterm.js) is worth it for everyone?

we can use WT_SESSION from #2256 to understand if we are in Windows Terminal.

@Kralizek commented on GitHub (Nov 12, 2019): > We had to do something similar for vscode's terminal. > > ``` > if ($env:TERM_PROGRAM -eq "vscode") { > Set-PSReadLineKeyHandler -Chord 'Ctrl+w' -Function BackwardKillWord > Set-PSReadLineKeyHandler -Chord 'Alt+D' -Function KillWord > Set-PSReadLineKeyHandler -Chord 'Ctrl+@' -Function MenuComplete > } > ``` > > Ctrl+Backspace gave us Ctrl+w > Ctrl+Spacebar gave us Ctrl+@ > > I actually added these as default keybindings in PSReadLine since vscode was such a common scenario. > > Perhaps some alignment with them (aka xterm.js) is worth it for everyone? we can use `WT_SESSION` from #2256 to understand if we are in Windows Terminal.
Author
Owner

@billgr commented on GitHub (Nov 26, 2019):

I've tried to use Terminal. I didn't realize how much I needed Ctrl+Backspace. I lasted about 2 hours and had to give up. I'll try again after this gets addressed.

@billgr commented on GitHub (Nov 26, 2019): I've tried to use Terminal. I didn't realize how much I needed Ctrl+Backspace. I lasted about 2 hours and had to give up. I'll try again after this gets addressed.
Author
Owner

@TylerLeonhardt commented on GitHub (Nov 27, 2019):

@billgr did you try the workaround?

@TylerLeonhardt commented on GitHub (Nov 27, 2019): @billgr did you try [the workaround](https://github.com/microsoft/terminal/issues/755#issuecomment-548529415)?
Author
Owner

@mahmoudajawad commented on GitHub (Nov 29, 2019):

@TylerLeonhardt, can you explain how to implement this workaround? I ran it in PS, as well as in $PROFILE but with no luck.

@mahmoudajawad commented on GitHub (Nov 29, 2019): @TylerLeonhardt, can you explain how to implement this workaround? I ran it in PS, as well as in `$PROFILE` but with no luck.
Author
Owner

@Kralizek commented on GitHub (Nov 29, 2019):

@TylerLeonhardt, can you explain how to implement this workaround? I ran it in PS, as well as in $PROFILE but with no luck.

Assuming you have psreadline installed, I have this snippet added into my $PROFILE.CurrentUserAllHosts

if ($env:WT_SESSION -ne $null)
{
	Set-PSReadLineKeyHandler -Key Ctrl+h -Function BackwardKillWord
}

This is a very rough solution but it works for me :)

@Kralizek commented on GitHub (Nov 29, 2019): > @TylerLeonhardt, can you explain how to implement this workaround? I ran it in PS, as well as in `$PROFILE` but with no luck. Assuming you have `psreadline ` installed, I have this snippet added into my `$PROFILE.CurrentUserAllHosts` ```powershell if ($env:WT_SESSION -ne $null) { Set-PSReadLineKeyHandler -Key Ctrl+h -Function BackwardKillWord } ``` This is a very rough solution but it works for me :)
Author
Owner

@mahmoudajawad commented on GitHub (Nov 30, 2019):

@Kralizek, thanks a lot. For some reasons it went the "It doesn't work for me, It works for you, and, now it works for me as well" scenario.

I'm glad this works now. But since you folks already tested this I'm pretty sure you are aware this doesn't work in WSL, right? And using:

stty werase ^H

will do the trick for WSL as well.

@mahmoudajawad commented on GitHub (Nov 30, 2019): @Kralizek, thanks a lot. For some reasons it went the "It doesn't work for me, It works for you, and, now it works for me as well" scenario. I'm glad this works now. But since you folks already tested this I'm pretty sure you are aware this doesn't work in WSL, right? And using: ```bash stty werase ^H ``` will do the trick for WSL as well.
Author
Owner

@mkitzan commented on GitHub (Dec 9, 2019):

@DHowett-MSFT I'm interested in implementing this and maybe Ctrl+Del while I'm at it. Any tips on starting? I haven't dug too deep into the VirtualTerminal part of WT.

@mkitzan commented on GitHub (Dec 9, 2019): @DHowett-MSFT I'm interested in implementing this and maybe Ctrl+Del while I'm at it. Any tips on starting? I haven't dug too deep into the VirtualTerminal part of WT.
Author
Owner

@DHowett-MSFT commented on GitHub (Dec 9, 2019):

@mkitzan sure! Here's the parts you'll want to look at.

  • VirtualTerminalInput - used in Cascadia (always) to determine what VT to generate for a given keypress
  • CONPTY PROCESS BOUNDARY (don't investigate this, i was just being unclever with my list layout)
  • InputStateMachineEngine - used in Conhost (here, hosting a conpty) to determine what key events a given piece of VT translates into
  • VirtualTerminalInput - used in Conhost (if the application has requested VT input) to determine what VT to generate for a given synthesized keypress 😄

The thing you'll need to care about is how VirtualTerminalInput is used between 0 and 2 times for every given piece of non-standard-character input.

@DHowett-MSFT commented on GitHub (Dec 9, 2019): @mkitzan sure! Here's the parts you'll want to look at. * `VirtualTerminalInput` - used in Cascadia (always) to determine what VT to generate for a given keypress * **CONPTY PROCESS BOUNDARY** (don't investigate this, i was just being unclever with my list layout) * `InputStateMachineEngine` - used in Conhost (here, hosting a conpty) to determine what key events a given piece of VT translates into * `VirtualTerminalInput` - used in Conhost (if the application has requested VT input) to determine what VT to generate for a given synthesized keypress :smile: The thing you'll need to care about is how `VirtualTerminalInput` is used between 0 and 2 times for every given piece of non-standard-character input.
Author
Owner

@mkitzan commented on GitHub (Dec 10, 2019):

Great, I'll look into this. Thanks.

@mkitzan commented on GitHub (Dec 10, 2019): Great, I'll look into this. Thanks.
Author
Owner

@mkitzan commented on GitHub (Dec 10, 2019):

Update: ESC\0x8 does what we want in WSL, but not in PS or CMD. Ctrl+Del works correctly out of the box in PS, but not in WSL or CMD. Still a work in progress ⛑.
For WSL power users (w/ a dev build) in the thread looking for a quick fix, replace L"\x8" to L"\x1b\x8". For WSL preview build folks, Alt+Ctrl+Backspace will do what you want out the box (sub-optimal as it is).
Actual footage of reaching conpty boundary during code tracing.
conpty-boundary

@mkitzan commented on GitHub (Dec 10, 2019): Update: `ESC\0x8` does what we want in WSL, but not in PS or CMD. <kbd>Ctrl+Del</kbd> works correctly out of the box in PS, but not in WSL or CMD. Still a work in progress ⛑. For WSL power users (w/ a dev build) in the thread looking for a quick fix, replace [`L"\x8"`](https://github.com/microsoft/terminal/blob/master/src/terminal/input/terminalInput.cpp#L174) to `L"\x1b\x8"`. For WSL preview build folks, <kbd>Alt+Ctrl+Backspace</kbd> will do what you want out the box (sub-optimal as it is). Actual footage of reaching conpty boundary during code tracing. ![conpty-boundary](https://user-images.githubusercontent.com/28279285/70508464-5a1d7600-1ae3-11ea-8494-34825978ce65.gif)
Author
Owner

@travisterrell commented on GitHub (Dec 10, 2019):

I want to give a thumbs-up for implementing this issue. It is a pretty standard shortcut, and has been present in the other windows shell emulators since...pretty much forever.

The PSReadLine and AHK solutions are fine, but I don't suppose there is any possibility of implementing this via a profiles.json shortcut? (i.e.
"command": "something", "keys": [ "ctrl+backspace" ]

I would assume not, since this setting seems to be primarily used for keymapping existing commands.

@travisterrell commented on GitHub (Dec 10, 2019): I want to give a thumbs-up for implementing this issue. It is a pretty standard shortcut, and has been present in the other windows shell emulators since...pretty much forever. The PSReadLine and AHK solutions are fine, but I don't suppose there is any possibility of implementing this via a profiles.json shortcut? (i.e. ` "command": "something", "keys": [ "ctrl+backspace" ]` I would assume not, since this setting seems to be primarily used for keymapping existing commands.
Author
Owner

@DHowett-MSFT commented on GitHub (Dec 10, 2019):

via a profiles.json shortcut

At its core, a terminal is a way to get text from one place to another. There is no command we can implement on the terminal side that will make a remote shell understand that we want to delete a whole word.

Our only option is to make sure we can pass through Ctrl+Backspace in a way the remote shell can understand.

@DHowett-MSFT commented on GitHub (Dec 10, 2019): > via a profiles.json shortcut At its core, a terminal is a way to get text from one place to another. There is no command we can implement on the _terminal_ side that will make a remote shell understand that we want to delete a whole word. Our only option is to make sure we can pass through <kbd>Ctrl+Backspace</kbd> in a way the remote shell can understand.
Author
Owner

@mkitzan commented on GitHub (Dec 12, 2019):

Got one message for all the good people in the thread
we-got-him

@zadjii-msft your comment was very helpful. Essentially just needed to reinterpret how InputStateMachine processes \b as a control character. I've also got small fixes to two other issues on my working branch. Do you mind if I make one PR which includes all three fixes, or would you prefer separate PRs for each?

@mkitzan commented on GitHub (Dec 12, 2019): Got one message for all the good people in the thread ![we-got-him](https://user-images.githubusercontent.com/28279285/70683793-958d8100-1c58-11ea-957e-efe9332a5695.gif) @zadjii-msft your [comment](https://github.com/microsoft/terminal/issues/755#issuecomment-498284872) was very helpful. Essentially just needed to reinterpret how `InputStateMachine` processes `\b` as a control character. I've also got small fixes to two other issues on my working branch. Do you mind if I make one PR which includes all three fixes, or would you prefer separate PRs for each?
Author
Owner

@ghost commented on GitHub (Jan 27, 2020):

:tada:This issue was addressed in #3935, which has now been successfully released as Windows Terminal Preview v0.8.10261.0.🎉

Handy links:

@ghost commented on GitHub (Jan 27, 2020): :tada:This issue was addressed in #3935, which has now been successfully released as `Windows Terminal Preview v0.8.10261.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v0.8.10261.0) * [Store Download](https://www.microsoft.com/store/apps/9n0dx20hk701?cid=storebadge&ocid=badge)
Author
Owner

@Nufflee commented on GitHub (May 10, 2020):

This issue still doesn't seem to be fixed in WSL1 terminals. Ctrl+Backspace doesn't work in a vanilla WSL1 terminal without the "bind" command provided earlier in this thread.
Am I doing something wrong or does this still not work across all terminals?

@Nufflee commented on GitHub (May 10, 2020): This issue still doesn't seem to be fixed in WSL1 terminals. <kbd>Ctrl+Backspace</kbd> doesn't work in a vanilla WSL1 terminal without the "bind" command provided earlier in this thread. Am I doing something wrong or does this still not work across all terminals?
Author
Owner

@jevring commented on GitHub (May 10, 2020):

@Nufflee even that bind command doesn't necessarily work in wsl1 anymore. It works on some machine, but not others. The one that does seem to work on all my machines right now is this: stty werase ^H

@jevring commented on GitHub (May 10, 2020): @Nufflee even that `bind` command doesn't necessarily work in wsl1 anymore. It works on some machine, but not others. The one that does seem to work on all my machines right now is this: `stty werase ^H`
Author
Owner

@Ensuperb commented on GitHub (May 23, 2020):

thx @jevring , it works for my bash

@Ensuperb commented on GitHub (May 23, 2020): thx @jevring , it works for my bash
Author
Owner

@lucky-wolf commented on GitHub (Jul 25, 2020):

I don't get it... ctrl+backspace doesn't delete word through ssh in a "Windows Terminal" (beta).
This functionality works if I use a terminal window through my linux VM. In fact, Ctrl+BS works in all windows in linux env., whether I'm remote shelled in or locally. It's a fairly universal keybinding in linux.

But for Windows Terminal - Ctrl+BS, Shift+BS, Ctrl+Shift+BS, Ctrl+Alt+BS, Alt+BS, etc. - every possible combo - does not a damn thing.

Is there some way to say "when I ssh - stop being tarded?" Or ???

Folks mention "it works now" - but under zero circumstances does it work.

What am I missing?

@lucky-wolf commented on GitHub (Jul 25, 2020): I don't get it... ctrl+backspace doesn't delete word through ssh in a "Windows Terminal" (beta). This functionality works if I use a terminal window through my linux VM. In fact, Ctrl+BS works in all windows in linux env., whether I'm remote shelled in or locally. It's a fairly universal keybinding in linux. But for Windows Terminal - Ctrl+BS, Shift+BS, Ctrl+Shift+BS, Ctrl+Alt+BS, Alt+BS, etc. - every possible combo - does not a damn thing. Is there some way to say "when I ssh - stop being tarded?" Or ??? Folks mention "it works now" - but under zero circumstances does it work. What am I missing?
Author
Owner

@DHowett commented on GitHub (Jul 25, 2020):

@lucky-wolf which version of the SSH client are you using? The one that came with Windows, 7.7, has some input bugs that result in it dropping certain keys even when “Windows Terminal” sends them.

We’ve worked it out with their team, and versions 8.1 and above should support everything the Terminal does.

If you’re using WSL and running SSH inside that, it would be very helpful if you’d file a new bug because that’s unexpected and undesirable behavior.

@DHowett commented on GitHub (Jul 25, 2020): @lucky-wolf which version of the SSH client are you using? The one that came with Windows, 7.7, has some input bugs that result in it dropping certain keys even when “Windows Terminal” sends them. We’ve worked it out with their team, and versions 8.1 and above should support everything the Terminal does. If you’re using WSL and running SSH inside that, it would be very helpful if you’d file a _new_ bug because that’s unexpected and undesirable behavior.
Author
Owner

@DHowett commented on GitHub (Jul 25, 2020):

Alright, now that I'm at my machine I can demonstrate this a little better. I've used the showkey utility (part of the kbd package on Ubuntu and Debian) to record the encoding for Ctrl+Backspace.

ssh under wsl

% wsl ssh -4 dustin@antares -t showkey -a

Press any keys - Ctrl-D will terminate this program

^H        8 0010 0x08
^D        4 0004 0x04
Connection to antares closed.

ssh 7.7 (win32-openssh, shipped with windows)

% ssh -V
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

% ssh dustin@antares -t showkey -a

Press any keys - Ctrl-D will terminate this program

^?      127 0177 0x7f
^D        4 0004 0x04
Connection to antares closed.

ssh 8.1 (win32-openssh, newer version from their repository)

% ssh8 -V
OpenSSH_for_Windows_8.1p1, LibreSSL 2.6.5

% ssh8 dustin@antares -t showkey -a

Press any keys - Ctrl-D will terminate this program

^H        8 0010 0x08
^D        4 0004 0x04
Connection to antares closed.

^H is the correct encoding, and ^? is not. Win32-OpenSSH did not, until version 8+, trust the windows console infrastructure to generate the right character encodings. It would do so itself and in so doing it got a bunch of them wrong. This was resolved by fixing PowerShell/Win32-OpenSSH#1310 in PR https://github.com/PowerShell/openssh-portable/pull/412.

@DHowett commented on GitHub (Jul 25, 2020): Alright, now that I'm at my machine I can demonstrate this a little better. I've used the `showkey` utility (part of the `kbd` package on Ubuntu and Debian) to record the encoding for <kbd>Ctrl+Backspace</kbd>. ### ssh under wsl ``` % wsl ssh -4 dustin@antares -t showkey -a Press any keys - Ctrl-D will terminate this program ^H 8 0010 0x08 ^D 4 0004 0x04 Connection to antares closed. ``` ### ssh 7.7 (win32-openssh, shipped with windows) ``` % ssh -V OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5 % ssh dustin@antares -t showkey -a Press any keys - Ctrl-D will terminate this program ^? 127 0177 0x7f ^D 4 0004 0x04 Connection to antares closed. ``` ### ssh 8.1 (win32-openssh, newer version from [their repository](https://github.com/powershell/win32-openssh/releases)) ``` % ssh8 -V OpenSSH_for_Windows_8.1p1, LibreSSL 2.6.5 % ssh8 dustin@antares -t showkey -a Press any keys - Ctrl-D will terminate this program ^H 8 0010 0x08 ^D 4 0004 0x04 Connection to antares closed. ``` `^H` is the correct encoding, and `^?` is not. Win32-OpenSSH did not, until version 8+, trust the windows console infrastructure to generate the right character encodings. It would [do so itself](https://github.com/PowerShell/openssh-portable/blob/8ab565c53f3619d6a1f5ac229e212cad8a52852c/contrib/win32/win32compat/tncon.c#L218-L847) and in so doing it got a bunch of them _wrong_. This was resolved by fixing PowerShell/Win32-OpenSSH#1310 in PR https://github.com/PowerShell/openssh-portable/pull/412.
Author
Owner

@lucky-wolf commented on GitHub (Jul 26, 2020):

Apologies. I am not 100% certain I'm in the right place? I'm on win 10, running the "Windows Terminal" app 1.1.2021.0.

I had installed that when I was trying to find a decent shell - and wanted something that could handle PS as well as WSL (which I had installed at the time). I've since removed WSL which I found cumbersome, but I've been trying to simply use this Windows Terminal as a solid remote shell interface - it seems to support bash/zsh colorizing through ssh to various linux boxes we use at work.

And for the most part, I was very happy with it - with the one exception: ctrl+backspace doesn't delete a word. Out of frustration I did a simple search on Windows Terminal and Ctrl+BS not working, and landed here with lots of folks indicating it works great.

So, is there some other windows terminal out there? Am I using Windows Terminal incorrectly (I'm starting from a power shell 5.1.18362.752. and then running ssh from there... maybe there's a better base shell to start from?)

I see that there are much later version of PS - so I'll upgrade to 7.03 now. I can reinstall WSL if that works better?
I'm not very interested in PS for any local work - though I don't mind learning a bit about a new shell - but 98% of what I need is a reliable flexible terminal to ssh into various linux boxes to do basic configuration / log gathering / troubleshooting --

And not having ctrl+backspace just makes the typing much harder then it needs to be (when the rest of the terminal experience is quite excellent).

And hmm... yes - I'm running:
ssh -v
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

That looks like my other half of the problem!

Sorry for being such a noob. This looks like the help I needed, @DHowett ! Much appreciated!


Update:

I've updated to power shell 7.03
Updated to OpenSSH_for_Windows_8.1p1, LibreSSL 2.9.2
but when I ssh8 into my linux box, ctrl+bs doesn't do word-delete.

If I do the exact same thing from my Mint VM using it's native terminal and ssh implementation, ctrl+bs works.

so I guess I'm still at a loss as to how to accomplish this? :/

@lucky-wolf commented on GitHub (Jul 26, 2020): Apologies. I am not 100% certain I'm in the right place? I'm on win 10, running the "Windows Terminal" app 1.1.2021.0. I had installed that when I was trying to find a decent shell - and wanted something that could handle PS as well as WSL (which I had installed at the time). I've since removed WSL which I found cumbersome, but I've been trying to simply use this Windows Terminal as a solid remote shell interface - it seems to support bash/zsh colorizing through ssh to various linux boxes we use at work. And for the most part, I was very happy with it - with the one exception: ctrl+backspace doesn't delete a word. Out of frustration I did a simple search on Windows Terminal and Ctrl+BS not working, and landed here with lots of folks indicating it works great. So, is there some *other* windows terminal out there? Am I using Windows Terminal incorrectly (I'm starting from a power shell 5.1.18362.752. and then running ssh from there... maybe there's a better base shell to start from?) I see that there are much later version of PS - so I'll upgrade to 7.03 now. I can reinstall WSL if that works better? I'm not very interested in PS for any local work - though I don't mind learning a bit about a new shell - but 98% of what I need is a reliable flexible terminal to ssh into various linux boxes to do basic configuration / log gathering / troubleshooting -- And not having ctrl+backspace just makes the typing much harder then it needs to be (when the rest of the terminal experience is quite excellent). And hmm... yes - I'm running: ssh -v OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5 That looks like my other half of the problem! Sorry for being such a noob. This looks like the help I needed, @DHowett ! Much appreciated! ---- Update: I've updated to power shell 7.03 Updated to OpenSSH_for_Windows_8.1p1, LibreSSL 2.9.2 but when I ssh8 into my linux box, ctrl+bs doesn't do word-delete. If I do the exact same thing from my Mint VM using it's native terminal and ssh implementation, ctrl+bs works. so I guess I'm still at a loss as to how to accomplish this? :/
Author
Owner

@rkeithhill commented on GitHub (Jul 26, 2020):

I had to execute the following command after opening the ssh connection to get Ctrl+Backspace to work on my Linux VMs:

stty werase ^h

Note that I'm on the latest Windows Terminal Preview and OpenSSH 8.1. BTW while that works in the bash shell you ssh into, once you start up pwsh on the remote, Ctrl+Backspace is back to deleting single chars. I tried the stty command in PowerShell, no joy.

@rkeithhill commented on GitHub (Jul 26, 2020): I had to execute the following command after opening the ssh connection to get Ctrl+Backspace to work on my Linux VMs: ``` stty werase ^h ``` Note that I'm on the latest Windows Terminal Preview and OpenSSH 8.1. BTW while that works in the `bash` shell you ssh into, once you start up `pwsh` on the remote, `Ctrl+Backspace` is back to deleting single chars. I tried the `stty` command in PowerShell, no joy.
Author
Owner

@BennyAlex commented on GitHub (Sep 18, 2020):

@DHowett-MSFT
why is this closed? It still occurs, at least in bash. In powershell and cmd it works fine for me.

@BennyAlex commented on GitHub (Sep 18, 2020): @DHowett-MSFT why is this closed? It still occurs, at least in bash. In powershell and cmd it works fine for me.
Author
Owner

@mkitzan commented on GitHub (Sep 19, 2020):

WSL based terminals do not delete whole words with Ctrl+Backspace

WSL does not interpret the Ctrl+Backspace virtual key sequence as "delete whole word" for whatever reason (not sure about WSL2). If you open any old WSL based terminal (like the Ubuntu shell from the MS store), Ctrl+Backspace will not delete whole words for this reason. If you want to delete whole words in a WSL based terminal, Ctrl+W will do it. Ctrl+Backspace works on CMD and PS because they process the virtual key sequence as expected.

(read the thread / PR, it's all there)

@mkitzan commented on GitHub (Sep 19, 2020): **WSL based terminals do not delete whole words with <kbd>Ctrl+Backspace</kbd>** WSL does not interpret the <kbd>Ctrl+Backspace</kbd> virtual key sequence as "delete whole word" for whatever reason (not sure about WSL2). If you open any old WSL based terminal (like the Ubuntu shell from the MS store), <kbd>Ctrl+Backspace</kbd> will not delete whole words for this reason. If you want to delete whole words in a WSL based terminal, <kbd>Ctrl+W</kbd> will do it. <kbd>Ctrl+Backspace</kbd> works on CMD and PS because they process the virtual key sequence as expected. (read the thread / PR, it's all there)
Author
Owner

@Animeshz commented on GitHub (Feb 15, 2021):

I don't know if its related @BennyAlex @mkitzan, but Alt+Backspace seems to work perfectly fine. Is there's any plan to be able to edit the hotkeys or not 🤔?

@Animeshz commented on GitHub (Feb 15, 2021): I don't know if its related @BennyAlex @mkitzan, but `Alt+Backspace` seems to work perfectly fine. Is there's any plan to be able to edit the hotkeys or not 🤔?
Author
Owner

@BennyAlex commented on GitHub (Feb 15, 2021):

@Animeshz it works fine if your using powershell or cmd, but if your using WLS or bash it wont.
In bash you have to add bind '"\C-H":backward-kill-word' to ~./bash.rc.

As you said, it wouldbe really nice to configurate this inside Terminal settings as a Hotkey/alias.

@BennyAlex commented on GitHub (Feb 15, 2021): @Animeshz it works fine if your using powershell or cmd, but if your using WLS or bash it wont. In bash you have to add `bind '"\C-H":backward-kill-word'` to ~./bash.rc. As you said, it wouldbe really nice to configurate this inside Terminal settings as a Hotkey/alias.
Author
Owner

@Animeshz commented on GitHub (Feb 15, 2021):

@BennyAlex It does, in WSL2 -> Ubuntu via the Alt+Backspace.

@Animeshz commented on GitHub (Feb 15, 2021): @BennyAlex It does, in WSL2 -> Ubuntu via the `Alt+Backspace`.
Author
Owner

@DHowett commented on GitHub (Feb 15, 2021):

As you said, it wouldbe really nice to configurate this inside Terminal settings as a Hotkey/alias.

Terminal cannot control how the connected application interprets keyboard input if that application doesn’t already have the feature you want. What you are asking for is impossible.

@DHowett commented on GitHub (Feb 15, 2021): > As you said, it wouldbe really nice to configurate this inside Terminal settings as a Hotkey/alias. Terminal _cannot_ control how the connected application interprets keyboard input if that application doesn’t already have the feature you want. What you are asking for is impossible.
Author
Owner

@Animeshz commented on GitHub (Feb 16, 2021):

@DHowett I see the VSCode is able to do so 👀. The Ctrl+Backspace is working with it. So I guess it shouldn't be "impossible" or so.

VSC-word-delete

@Animeshz commented on GitHub (Feb 16, 2021): @DHowett I see the VSCode is able to do so 👀. The `Ctrl+Backspace` is working with it. So I guess it shouldn't be "impossible" or so. ![VSC-word-delete](https://user-images.githubusercontent.com/26714676/108013480-c8d45880-7031-11eb-9a87-d7d74976fc1d.gif)
Author
Owner

@BennyAlex commented on GitHub (Feb 16, 2021):

As you said, it wouldbe really nice to configurate this inside Terminal settings as a Hotkey/alias.

Terminal cannot control how the connected application interprets keyboard input if that application doesn’t already have the feature you want. What you are asking for is impossible.

If the terminal would send something like bind '"\C-H":backward-kill-word' to bash or if thats not possible, it coud change the .bashrc by itself automatically.

I am not very familiar with how Terminals work, but I saw different ones where ctrl-backspace deletes the whole word without any configuration

@BennyAlex commented on GitHub (Feb 16, 2021): > > As you said, it wouldbe really nice to configurate this inside Terminal settings as a Hotkey/alias. > > Terminal _cannot_ control how the connected application interprets keyboard input if that application doesn’t already have the feature you want. What you are asking for is impossible. If the terminal would send something like `bind '"\C-H":backward-kill-word'` to bash or if thats not possible, it coud change the .bashrc by itself automatically. I am not very familiar with how Terminals work, but I saw different ones where ctrl-backspace deletes the whole word without any configuration
Author
Owner

@zadjii-msft commented on GitHub (Feb 16, 2021):

I would love to have another actual, concrete example of a terminal that allows C-bksp to delete whole words backwards, without otherwise configuring bash to so do.

VsCode does this by manually binding

{ "key": "ctrl+backspace",        "command": "workbench.action.terminal.deleteWordLeft",
                                     "when": "terminalFocus" },

Which then presumably sends ^W to the terminal. (see https://github.com/microsoft/vscode/issues/31821, https://github.com/microsoft/vscode/issues/59071). I wouldn't recommend that, because it's not always going to work, but hey, they've already made that decision. You could probably get the same behavior in the Windows Terminal with

{ "keys": "ctrl+backspace", "command": { "action": "sendInput", "input": "\u0017" },
@zadjii-msft commented on GitHub (Feb 16, 2021): I would _love_ to have another actual, concrete example of a terminal that allows `C-bksp` to delete whole words backwards, _without_ otherwise configuring bash to so do. VsCode does this by manually binding ```json { "key": "ctrl+backspace", "command": "workbench.action.terminal.deleteWordLeft", "when": "terminalFocus" }, ``` Which then presumably sends `^W` to the terminal. (see https://github.com/microsoft/vscode/issues/31821, https://github.com/microsoft/vscode/issues/59071). I wouldn't recommend that, because it's not always going to work, but hey, they've already made that decision. You could _probably_ get the same behavior in the Windows Terminal with ```json { "keys": "ctrl+backspace", "command": { "action": "sendInput", "input": "\u0017" }, ```
Author
Owner

@BennyAlex commented on GitHub (Feb 16, 2021):

@zadjii-msft
As you said, VS Code is sending ^W, so I suggest other Terminals does that as well. As far as I can remember, cmder for windows was also able to deleteWordLeft inside bash

@BennyAlex commented on GitHub (Feb 16, 2021): @zadjii-msft As you said, VS Code is sending ^W, so I suggest other Terminals does that as well. As far as I can remember, cmder for windows was also able to deleteWordLeft inside bash
Author
Owner

@GaboFrontDev commented on GitHub (Mar 10, 2021):

I would love to have another actual, concrete example of a terminal that allows C-bksp to delete whole words backwards, without otherwise configuring bash to so do.

VsCode does this by manually binding

{ "key": "ctrl+backspace",        "command": "workbench.action.terminal.deleteWordLeft",
                                     "when": "terminalFocus" },

Which then presumably sends ^W to the terminal. (see microsoft/vscode#31821, microsoft/vscode#59071). I wouldn't recommend that, because it's not always going to work, but hey, they've already made that decision. You could probably get the same behavior in the Windows Terminal with

{ "keys": "ctrl+backspace", "command": { "action": "sendInput", "input": "\u0017" },

Thanks, I was looking for the action name. How can I find all the actions? Because there is no docs about it

@GaboFrontDev commented on GitHub (Mar 10, 2021): > I would _love_ to have another actual, concrete example of a terminal that allows `C-bksp` to delete whole words backwards, _without_ otherwise configuring bash to so do. > > VsCode does this by manually binding > > ```json > { "key": "ctrl+backspace", "command": "workbench.action.terminal.deleteWordLeft", > "when": "terminalFocus" }, > ``` > > Which then presumably sends `^W` to the terminal. (see [microsoft/vscode#31821](https://github.com/microsoft/vscode/issues/31821), [microsoft/vscode#59071](https://github.com/microsoft/vscode/issues/59071)). I wouldn't recommend that, because it's not always going to work, but hey, they've already made that decision. You could _probably_ get the same behavior in the Windows Terminal with > > ```json > { "keys": "ctrl+backspace", "command": { "action": "sendInput", "input": "\u0017" }, > ``` Thanks, I was looking for the action name. How can I find all the actions? Because there is no docs about it
Author
Owner

@zadjii-msft commented on GitHub (Mar 10, 2021):

Because there is no docs about it

https://docs.microsoft.com/en-us/windows/terminal/customize-settings/actions ????

@zadjii-msft commented on GitHub (Mar 10, 2021): > Because there is no docs about it https://docs.microsoft.com/en-us/windows/terminal/customize-settings/actions ?<sup>?</sup><sub>?</sub>?
Author
Owner

@GaboFrontDev commented on GitHub (Mar 10, 2021):

Because there is no docs about it

https://docs.microsoft.com/en-us/windows/terminal/customize-settings/actions ????

Yeah, I didn't understand the usage of sendInput too well. mb

@GaboFrontDev commented on GitHub (Mar 10, 2021): > > Because there is no docs about it > > https://docs.microsoft.com/en-us/windows/terminal/customize-settings/actions ???? Yeah, I didn't understand the usage of sendInput too well. mb
Author
Owner

@travisterrell commented on GitHub (Mar 11, 2021):

I would love to have another actual, concrete example of a terminal that allows C-bksp to delete whole words backwards, without otherwise configuring bash to so do.

VsCode does this by manually binding

{ "key": "ctrl+backspace",        "command": "workbench.action.terminal.deleteWordLeft",
                                     "when": "terminalFocus" },

Which then presumably sends ^W to the terminal. (see microsoft/vscode#31821, microsoft/vscode#59071). I wouldn't recommend that, because it's not always going to work, but hey, they've already made that decision. You could probably get the same behavior in the Windows Terminal with

{ "keys": "ctrl+backspace", "command": { "action": "sendInput", "input": "\u0017" },

Does the default Windows Command Prompt not count?

@travisterrell commented on GitHub (Mar 11, 2021): > > > I would _love_ to have another actual, concrete example of a terminal that allows `C-bksp` to delete whole words backwards, _without_ otherwise configuring bash to so do. > > VsCode does this by manually binding > > ```json > { "key": "ctrl+backspace", "command": "workbench.action.terminal.deleteWordLeft", > "when": "terminalFocus" }, > ``` > > Which then presumably sends `^W` to the terminal. (see [microsoft/vscode#31821](https://github.com/microsoft/vscode/issues/31821), [microsoft/vscode#59071](https://github.com/microsoft/vscode/issues/59071)). I wouldn't recommend that, because it's not always going to work, but hey, they've already made that decision. You could _probably_ get the same behavior in the Windows Terminal with > > ```json > { "keys": "ctrl+backspace", "command": { "action": "sendInput", "input": "\u0017" }, > ``` Does the default Windows Command Prompt not count?
Author
Owner

@zadjii-msft commented on GitHub (Mar 12, 2021):

Does the default Windows Command Prompt not count?

Ah but "Command Prompt" isn't a terminal emulator, it's a shell. Which does bring us to a complicated scenario - technically, the ctrl+bksp handler in cmd.exe technically is implemented in conhost. But that's provided by the "cooked read data", which is an input mode that commandline applications can request in console apps. Using cooked read is a little bit like having a bad readline that's implemented for you, by the console subsystem itself. So technically, that's provided in conhost, but that's really a per-client application kind of thing. WSL, for example, disables cooked read, so it can read individual keystrokes.

@zadjii-msft commented on GitHub (Mar 12, 2021): > Does the default Windows Command Prompt not count? Ah but "Command Prompt" isn't a _terminal emulator_, it's a shell. Which does bring us to a complicated scenario - technically, the <kbd>ctrl+bksp</kbd> handler in `cmd.exe` technically is implemented in conhost. But that's provided by the "cooked read data", which is an input mode that commandline applications can request in console apps. Using cooked read is a little bit like having a bad `readline` that's implemented for you, by the console subsystem itself. So _technically_, that's provided in conhost, but that's really a per-client application kind of thing. WSL, for example, disables cooked read, so it can read individual keystrokes.
Author
Owner

@travisterrell commented on GitHub (Mar 12, 2021):

Ah, that makes a large amount of sense. Thank you very much for the information. It totally makes sense that when Terminal connects to other shells, it must accommodate different behavior.

Thanks again!

@travisterrell commented on GitHub (Mar 12, 2021): Ah, that makes a large amount of sense. Thank you very much for the information. It totally makes sense that when Terminal connects to other shells, it must accommodate different behavior. Thanks again!
Author
Owner

@flyingdutchman commented on GitHub (Mar 12, 2021):

When trying to do verbatim insert ctrl+v on my linux machine over ssh my backspace and ctrl+bksp both output ^? on my terminal. Thus I can't change my .inputrc file to correct the problem.

I do realize that this can be fixed by creating a new action in the Windows Terminal parameters but is this strange behavior linked to Windows Terminal or is it something else ?

@flyingdutchman commented on GitHub (Mar 12, 2021): When trying to do verbatim insert `ctrl+v` on my linux machine over ssh my backspace and `ctrl+bksp` both output `^?` on my terminal. Thus I can't change my `.inputrc` file to correct the problem. I do realize that this can be fixed by creating a new action in the Windows Terminal parameters but is this strange behavior linked to Windows Terminal or is it something else ?
Author
Owner

@DHowett commented on GitHub (Mar 12, 2021):

Depends. Are you using the bundled 7.7 version of SSH that comes with Windows?

@DHowett commented on GitHub (Mar 12, 2021): Depends. Are you using the bundled 7.7 version of SSH that comes with Windows?
Author
Owner

@flyingdutchman commented on GitHub (Apr 12, 2021):

Sorry for the late answer !

After checking, yes I have the built in version OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
I'll wait for the windows 10 update that will come with a newer version to see if the behavior changes.

@flyingdutchman commented on GitHub (Apr 12, 2021): Sorry for the late answer ! After checking, yes I have the built in version OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5 I'll wait for the windows 10 update that will come with a newer version to see if the behavior changes.
Author
Owner

@flatline-studios commented on GitHub (May 17, 2021):

Sorry for the late answer !

After checking, yes I have the built in version OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
I'll wait for the windows 10 update that will come with a newer version to see if the behavior changes.

The version 8.1 of OpenSSH came out nearly two years ago... It doesn't look like microsoft is in any hurry to push it out over windows update, so you could be waiting a looooong time (as in, forever).

Why not just:

  1. Grab the .zip from: https://github.com/PowerShell/Win32-OpenSSH/releases
  2. Unzip it somewhere awesome, like: C:\Program Files\OpenSSH
  3. Add the directory in part 2, to the top of the PATH environment variable (Google knows how)
  4. Close and re-open your terminal to force an update of the newly updated PATH
  5. Type: get-command ssh in to a PowerShell window, and check that it's Version 8.1.0.0, or greater

It'll take less than a minute if you know how to add to your PATH variable, maybe 3 or 4 minutes if you don't.

@flatline-studios commented on GitHub (May 17, 2021): > Sorry for the late answer ! > > After checking, yes I have the built in version OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5 > I'll wait for the windows 10 update that will come with a newer version to see if the behavior changes. The version 8.1 of OpenSSH came out nearly two years ago... It doesn't look like microsoft is in any hurry to push it out over windows update, so you could be waiting a looooong time (as in, forever). Why not just: 1) Grab the .zip from: https://github.com/PowerShell/Win32-OpenSSH/releases 2) Unzip it somewhere awesome, like: `C:\Program Files\OpenSSH` 3) Add the directory in part 2, to the top of the PATH environment variable (Google knows how) 4) Close and re-open your terminal to force an update of the newly updated PATH 5) Type: `get-command ssh` in to a PowerShell window, and check that it's Version `8.1.0.0`, or greater It'll take less than a minute if you know how to add to your PATH variable, maybe 3 or 4 minutes if you don't.
Author
Owner

@Gorthog commented on GitHub (Jan 9, 2022):

If you are using fish shell you can add these 2 lines in your $HOME/.config/fish/config.fish:

bind \cH backward-kill-path-component
bind \[3\;5~ kill-word
@Gorthog commented on GitHub (Jan 9, 2022): If you are using fish shell you can add these 2 lines in your $HOME/.config/fish/config.fish: ``` bind \cH backward-kill-path-component bind \[3\;5~ kill-word ```
Author
Owner

@tqwewe commented on GitHub (May 7, 2022):

Fish shell users: Fish automatically calls a function called fish_user_key_bindings.

Add the following to ~/.config/fish/config.fish:

function fish_user_key_bindings
    # Ctrl Left Arrow
    bind \e\[1\;5D backward-word
    # Ctrl Right Arrow
    bind \e\[1\;5C forward-word
    # Ctrl backspace
    bind \b backward-kill-word
end
@tqwewe commented on GitHub (May 7, 2022): Fish shell users: Fish automatically calls a function called `fish_user_key_bindings`. Add the following to `~/.config/fish/config.fish`: ```fish function fish_user_key_bindings # Ctrl Left Arrow bind \e\[1\;5D backward-word # Ctrl Right Arrow bind \e\[1\;5C forward-word # Ctrl backspace bind \b backward-kill-word end ```
Author
Owner

@Naolador commented on GitHub (Jul 4, 2022):

Fish shell users: Fish automatically calls a function called fish_user_key_bindings.

Add the following to ~/.config/fish/config.fish:

function fish_user_key_bindings
    # Ctrl Left Arrow
    bind \e\[1\;5D backward-word
    # Ctrl Right Arrow
    bind \e\[1\;5C forward-word
    # Ctrl backspace
    bind \b backward-kill-word
end

That's not working on my fish, version 3.5.0.

@Naolador commented on GitHub (Jul 4, 2022): > Fish shell users: Fish automatically calls a function called `fish_user_key_bindings`. > > Add the following to `~/.config/fish/config.fish`: > > ```fish > function fish_user_key_bindings > # Ctrl Left Arrow > bind \e\[1\;5D backward-word > # Ctrl Right Arrow > bind \e\[1\;5C forward-word > # Ctrl backspace > bind \b backward-kill-word > end > ``` That's not working on my fish, version 3.5.0.
Author
Owner

@Gorthog commented on GitHub (Jul 27, 2022):

@Naolador ctrl + left / right arrow works fine without any additional configuration

for ctrl + backspace try this:

function fish_user_key_bindings
    # ctrl + backspace to delete previous word
    bind \cH backward-kill-path-component
    # ctrl + delete to to delete forward word
    bind \[3\;5~ kill-word
end
@Gorthog commented on GitHub (Jul 27, 2022): @Naolador ctrl + left / right arrow works fine without any additional configuration for ctrl + backspace try this: ``` function fish_user_key_bindings # ctrl + backspace to delete previous word bind \cH backward-kill-path-component # ctrl + delete to to delete forward word bind \[3\;5~ kill-word end ```
Author
Owner

@Naolador commented on GitHub (Jul 28, 2022):

@Naolador ctrl + left / right arrow works fine without any additional configuration

for ctrl + backspace try this:

function fish_user_key_bindings
    # ctrl + backspace to delete previous word
    bind \cH backward-kill-path-component
    # ctrl + delete to to delete forward word
    bind \[3\;5~ kill-word
end

Thanks, that works 👍

@Naolador commented on GitHub (Jul 28, 2022): > @Naolador ctrl + left / right arrow works fine without any additional configuration > > for ctrl + backspace try this: > > ``` > function fish_user_key_bindings > # ctrl + backspace to delete previous word > bind \cH backward-kill-path-component > # ctrl + delete to to delete forward word > bind \[3\;5~ kill-word > end > ``` Thanks, that works 👍
Author
Owner

@unphased commented on GitHub (Aug 17, 2022):

Note for googlers that land here like me.

I came here because I use Ctrl+H to move to the left pane in tmux and vim, and I use Ctrl+Backspace to delete a word backwards. I am used to making adjustments to ensure that all three work.

The way to make this work for Windows Terminal (which is growing so well and I no longer try to run Alacritty on windows anymore, and haven't ran Putty in years) to be consistent with what I believe to be the ideal modern Linux and BSD mapping of these keys:

	{ "command": { "action": "sendInput", "input": "\u007f" }, "keys": "backspace" },
	{ "command": { "action": "sendInput", "input": "\u001b\u007f" }, "keys": "ctrl+backspace" }
@unphased commented on GitHub (Aug 17, 2022): Note for googlers that land here like me. I came here because I use Ctrl+H to move to the left pane in tmux and vim, and I use Ctrl+Backspace to delete a word backwards. I am used to making adjustments to ensure that all three work. The way to make this work for Windows Terminal (which is growing so well and I no longer try to run Alacritty on windows anymore, and haven't ran Putty in years) to be consistent with what I believe to be the ideal modern Linux and BSD mapping of these keys: ``` { "command": { "action": "sendInput", "input": "\u007f" }, "keys": "backspace" }, { "command": { "action": "sendInput", "input": "\u001b\u007f" }, "keys": "ctrl+backspace" } ```
Author
Owner

@junaga commented on GitHub (Jan 20, 2023):

TLDR

fix either in bash

# ~/.bashrc
bind '"\C-H":backward-kill-word'

or in wt.exe (Windows Terminal)

// %LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json
{
  "actions": [
    {
      "keys": "ctrl+backspace",
      "command": { "action": "sendInput", "input": "\u0017" }
    }
  ]
}
@junaga commented on GitHub (Jan 20, 2023): ## TLDR fix either in `bash` ```bash # ~/.bashrc bind '"\C-H":backward-kill-word' ``` or in `wt.exe` (Windows Terminal) ```jsonc // %LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json { "actions": [ { "keys": "ctrl+backspace", "command": { "action": "sendInput", "input": "\u0017" } } ] } ```
Author
Owner

@l4kr commented on GitHub (Jun 21, 2024):

One more solution which is easily reversible and works accross all shells, all SSH sessions, and your grandmas and their dogs computer is in PowerToys - Keybard Manager > Remap shortcuts > Add shortcut remapping

Ctrl+Backspace to Alt+Backspace in app "windowsterminal"

image

@l4kr commented on GitHub (Jun 21, 2024): One more solution which is easily reversible and works accross all shells, all SSH sessions, and your grandmas and their dogs computer is in PowerToys - Keybard Manager > Remap shortcuts > Add shortcut remapping Ctrl+Backspace to Alt+Backspace in app "windowsterminal" ![image](https://github.com/microsoft/terminal/assets/73653844/e801750c-dc05-44d0-b0e8-8c22ec4f1d47)
Author
Owner

@shameoff commented on GitHub (Aug 2, 2025):

Cool solution, @l4kr! But I would prefer

Ctrl+Backspace to Ctrl+W in app "windowsterminal"

because afaik this is default keymap for deleting backword in many popular terminals, including PowerShell

Yep, let's continue necroposting

@shameoff commented on GitHub (Aug 2, 2025): Cool solution, @l4kr! But I would prefer > Ctrl+Backspace to **Ctrl+W** in app "windowsterminal" because afaik this is default keymap for deleting backword in many popular terminals, including PowerShell Yep, let's continue necroposting
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#1034