Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

bash

readline

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.

like image 482
malana Avatar asked Jun 11 '12 12:06

malana


Video Answer


1 Answers

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

stty werase undef
bind '"\C-w":kill-region'
like image 83
Dennis Williamson Avatar answered Nov 15 '22 20:11

Dennis Williamson