I'd like to map Ctrl-w to kill-region
in Bash 4.2. This key is bound to unix-word-rubout
(delete word backward) by default. According to the manual, remapping should be possible with the bind
command which has the options
-u function Unbind all keys bound to the named function.
-r keyseq Remove any current binding for keyseq.
I tried bind -r "\C-w"
and bind -u unix-word-rubout
but the key is not unset and, as bind -P | grep unix-word-rubout
reveals, there was no change in the mapping.
I played with bind
a little and I'm able to unbind other built-in keys but not Ctrl-w.
Ctrl-w is bound in stty
to werase
. You will need to unbind it there first.
stty werase undef
bind '"\C-w":kill-region'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With