4

I have read a number of answers to similar questions both in this forum and elsewhere, but I cannot make it work for me.

I am trying to remap Ctrl+W to delete the word forward rather than backward. I know that I can use Esc+D do do this, but this is also a learning exercise for me.

Using what I have read, I have added the following in ~/.inputrc:

$include /etc/inputrc
Control-w: kill-word
  • The first line is, apparently, required if I want to include the other bindings.
  • For the second, I have tried Control-w and "\C-w", and for the command, I have tried kill-word and shell-kill-word.
  • To try out the changes I have tried bind -f ~/.inputrc, Ctrl+X, Ctrl+R, bash -l and simply opening up a new terminal.

I assume that I have missed some important step, or simply misunderstood, but I’m running out of ideas.

I am on Centos 8.

3
  • Have you tried Control-W? Commented Jul 13, 2020 at 9:38
  • 1
    Did you see this post on SO? stackoverflow.com/q/10980575 Commented Jul 13, 2020 at 10:34
  • The question about re-binding ^C-w has answers, but it'd also be great to know where the precedence of terminal driver settings over Readline bindings is documented. Commented Jul 13, 2020 at 11:40

1 Answer 1

3

The readline library (which is what inputrc configures) sets up bindings corresponding to the bindings of the terminal driver for cooked input. These are commonly known as stty keys because they can be configured with the command stty. Ctrl+W is the binding for deleting the previous word (werase) in the cooked terminal interface.

Those bindings take precedence over explicit bindings in .inputrc. To turn off this behavior, add this line to your .inputrc:

set bind-tty-special-chars off

If you haven't configured non-default cooked terminal key bindings with stty, I think this won't affect your bash bindings.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.