How can I delete a word backward at the command line? I'm truly used to some editors deleting the last 'word' using Ctrl+Backspace, and I'd like that functionality at the command line too.
I am using Bash at the moment and although I could jump backward a word and then delete forward a word, I'd rather have this as a quick-key, or event as Ctrl+Backspace.
How can accomplish this?
Best Answer
Ctrl+W is the standard "kill word" (aka
werase
). Ctrl+U kills the whole line (kill
).You can change them with
stty
.Note that one does not have to put the actual control character on the line,
stty
understands putting^
and then the character you would hit with control.After doing this, if I hit Ctrl+P it will erase a word from the line. And if I hit Ctrl+A, it will erase the whole line.