How to delete words in the terminal with Ctrl-Backspace like in the rest of Ubuntu?

When I'm in a text in any program (browser, text editer, IDE) I can delete 3 words by holding Ctrl and pressing Backspace 3 times.

This works perfectly in all programs, except for the terminal. In the terminal Ctrl+Backspace simply deletes one letter, and I need Alt+Backspace to delete whole words.

Since I constantly switch between the terminal and other programs this is really annoying.

I tried the tip I found here (creating ~/.inputrc containing "\C-?":"\C-W") but that doesn't work for me. Now it deletes the whole word when I just press Backspace, but Ctrl+Backspace still just removes one letter.

Does anybody know how I can change this behaviour so that Ctrl+Backspace deletes the word left of the cursor? All tips are welcome!


This is not generally possible for bash by itself without help from the terminal emulator, because Backspace is usually the same keycode as Ctrl+? (ASCII DEL) (or Ctrl+H - ASCII backspace). (Try Ctrl+V then Backspace to verify.) That makes Ctrl+Backspace essentially Ctrl+Ctrl+? ... which is just Ctrl+? or simply Backspace itself.*)

With some terminal emulators, there are settings which allow you to send custom keycodes for various key combinations. In particular, many have an option to customize what Backspace sends (to switch between ASCII DEL or backspace, usually). You might want to experiment with such options to see if the terminal emulator sends a different keycode for H and Ctrl+Backspace.


* This also true for a number of special keys - Enter is Ctrl+M, Tab is Ctrl+I, Esc is Ctrl+], etc.