-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ctrl-backspace does not delete back to the previous wordbreak #755
Comments
I don't see the keybinding in the terminal app, it might not be implemented. |
@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. |
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. |
FYI, if you launch PowerShell through WSL, |
Apparently |
Yea this might be a PSReadline thing TBH. I bet they're looking for an Then, when conpty recieves the This might be solvable with the whole conpty INPUT_RECORD thing |
Regular PowerShell does delete back till previous wordbreak so I'd expect the PowerShell tabs in Windows Terminal to do the same. |
good, that's why this is a bug that's still open and not resolved as By Design |
@lzybkr @daxian-dbw Any thoughts on this? It is a bummer that |
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: |
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. |
I'd also love to see this fixed! Definitely a jarring change from using regular PowerShell. |
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. |
I'm using zsh as my shell in WSL. When using This is my configuration: bindkey -e
# Control + backspace
bindkey '^H' backward-kill-word
# Control + arrows
bindkey ";5C" forward-word
bindkey ";5D" backward-word |
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) |
Some history on Ctrl+Backspace: https://devblogs.microsoft.com/oldnewthing/?p=24823 |
Use |
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 I see the VSCode is able to do so 👀. The |
If the terminal would send something like I am not very familiar with how Terminals work, but I saw different ones where ctrl-backspace deletes the whole word without any configuration |
I would love to have another actual, concrete example of a terminal that allows VsCode does this by manually binding { "key": "ctrl+backspace", "command": "workbench.action.terminal.deleteWordLeft",
"when": "terminalFocus" }, Which then presumably sends { "keys": "ctrl+backspace", "command": { "action": "sendInput", "input": "\u0017" }, |
@zadjii-msft |
Thanks, I was looking for the action name. How can I find all the actions? 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 |
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 |
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! |
When trying to do verbatim insert 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 ? |
Depends. Are you using the bundled 7.7 version of SSH that comes with Windows? |
Sorry for the late answer ! After checking, yes I have the built in version OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5 |
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:
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. |
If you are using fish shell you can add these 2 lines in your $HOME/.config/fish/config.fish:
|
Fish shell users: Fish automatically calls a function called Add the following to 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 ctrl + left / right arrow works fine without any additional configuration for ctrl + backspace try this:
|
Thanks, that works 👍 |
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:
|
TLDRfix either in # ~/.bashrc
bind '"\C-H":backward-kill-word' or in // %LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json
{
"actions": [
{
"keys": "ctrl+backspace",
"command": { "action": "sendInput", "input": "\u0017" }
}
]
} |
windowsではctrl+wをバインドできなかった。 microsoft/terminal#755 そもそもブラウザのタブ削除とも間違いやすいしまあいいかと
It deletes character-by-character instead.
The text was updated successfully, but these errors were encountered: