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!

  • Press Ctrl + W ("W" for word). – Jos Mar 19 '18 at 12:18
  • @Jos - I know that one, and I could also use Alt+backspace, but I simply want it to be the same across all programs. – kramer65 Mar 19 '18 at 12:23

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.

  • I'm using Tilix as an emulator. In the quick keys setting I can't really find the option to set this specific thing though. Do you know if this is possible for Tilix, or do you otherwise know another terminal which can do this? – kramer65 Mar 19 '18 at 14:12
  • I use Terminator, which has the odd behaviour that, if I set Backspace to send Ctrl-H, then Backspace is Ctrl-H, but Ctrl-Backspace is Ctrl-?. But looking at the docs, the screenshot in gnunn1.github.io/tilix-web/manual/vteconfig shows a "Compatibility" tab in the Profiles section. That's where the option in Terminator is. – muru Mar 19 '18 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.