Ubuntu – Getting + to delete words in gnome-terminal and vim insert mode

command linegnome-terminalgvimvim

It seems like ctrl + W deletes backwards one word at a time. That's great, but I'd really really like that this works with ctrl + backspace like most other apps.

What's the best way to do this? I'd need the change to affect gnome-terminal commands, command line vim and GUI vim.

Best Answer

[ for gnome-terminal ]

use stty tool, good for visualzing what bash keyboard shortcuts are binded.

see your current bash keyboard shortcuts (my system output):

stty -a

my output:

speed 38400 baud; rows 41; columns 76; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z;
rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon
-ixoff -iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0
ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc

werase is responsbile for deleting an entire word.

running this will set ctrl + backspace to erase a word when pressed.

stty werase \^H

!note: this will set this option only to your current terminal/bash session. in order to apply this permanently you need to add previous command to .bashrc file at the end of it.

settings from .bashrc will be loaded every time you open gnome-terminal.

after this you are ready to go. enjoy.