How to configure zsh such that Ctrl+Backspace kills the word before point? How to achieve that Ctrl+Delete kills the word after point?
I use urxvt as terminal emulator.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
I'll focus on Ctrl+Delete first.
The zsh command to delete a whole word forwards is called
kill-word. By default it is bound to Alt+D.
How to make Ctrl+Delete do it too depends on which terminal emulator you are using.
On my system, this works in xterm and Gnome Terminal:
bindkey -M emacs '^[[3;5~' kill-word
and for urxvt, you should do:
bindkey -M emacs '^[[3^' kill-word
If that doesn't work, try typing Ctrl+V Ctrl+Delete to see what the value is on your system.
You could even add both of those together to your
.zshrc, or use the output of
tput kDC5 instead of hard-coding the sequence.
Ctrl+Backspace seems harder.
On my system, pressing that is the same as pressing just Backspace.
If yours is the same, I think your best option is to use Alt+Backspace or Ctrl+W instead.
I've got this in my
and that in my
bindkey -M main -M viins -M vicmd '^[[33~' backward-kill-word
This kills each whitespace seperated word. Note that '^[' is the Escape character. You have to
xrdb -load .Xresources, open a terminal and then hit
^V followed by
showkey -a in your
zsh, and enter the key combination(s) that you want (e.g. Ctrl + Backspace). I'm also using
zsh and for me:
Ctrl + Backspace is
Ctrl + Delete is
Then in your
.zshrc file, add these lines:
# Ctrl+Backspace: kill the word backward bindkey -M emacs '^H' backward-kill-word bindkey -M viins '^H' backward-kill-word bindkey -M vicmd '^H' backward-kill-word # Ctrl+Delete: kill the word forward bindkey -M emacs '^[[3;5~' kill-word bindkey -M viins '^[[3;5~' kill-word bindkey -M vicmd '^[[3;5~' kill-word