How can I unbind and remap C-w in Bash? How can I unbind and remap C-w in Bash? bash bash

How can I unbind and remap C-w in Bash?


Ctrl-w is bound in stty to werase. You will need to unbind it there first.

stty werase undefbind '"\C-w":kill-region'


By default, readline attempts to bind the control characters treated specially by the kernel's terminal driver to their readline equivalents. (To see how your terminal is configured, run

stty -a

.) Your terminal presumably has Ctrl-w set to werase, so bash binds it to unix-word-rubout. This binding takes precedence over any keybindings that you specify in ~/.inputrc.

To avoid this mapping, you need to set the readline variable bind-tty-special-chars to off in your ~/.inputrc file:

set bind-tty-special-chars off