zsh kill Ctrl + Backspace, Ctrl + Delete
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.
On urxvt, for the deleting backwards part, I simply have in my .zshrc
the following:
bindkey '^H' backward-kill-word
and it allows me to delete the previous word with ctrl+backspace
Add the following to your ~/.zshrc
bindkey '^H' backward-kill-word
bindkey '5~' kill-word