stty -a


speed 38400 baud; rows 39; columns 143; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;

Here, i am not seeing M-DEL which is the emacs styled shortcut for delete one word backward.

What is the stty subcommand i can use to remap the key for backward-delete-word?

  • 1
    It's ^W. And ^U for the whole line. Why do you have eol and wol2 set to the same thing? And swtch? Weird.
    – mikeserv
    Jul 28, 2015 at 3:11
  • i didn't change anything for eol, wol2... i never use them, and in fact, don't know what those abbreviations are
    – user93868
    Jul 28, 2015 at 3:18
  • Well, that was a typo. They're End of Line and End of Line 2. They're mapped to Mod-Delete, it looks like - octal 377 or decimal byte 255. I guess probably your terminal or getty script or whatever set it up that way. try: (trap "stty $(stty -g;stty eol A)" 0; cat); then type an A and try to backspace over it. Use CTRL+D or CTRL+C to quit cat. Or (trap "stty $(stty -g;stty -echo eol A)" 0; cat) and type some stuff without entering a newline, then type A and see what happens. Usually those are null or \0 or ^- by default as far as I'm aware - so unassigned - but yours are set.
    – mikeserv
    Jul 28, 2015 at 3:36

1 Answer 1


M-Del is just an emacs key binding. It's not something typically interpreted by the in-kernel tty driver. Backwards word erase, or werase, is set to control-W (^W) in your stty -a output.

The kernel works on bytes, and so if you use a UTF-8 encoding, it will be hard to bind non-ASCII characters to werase. In fact, M-Del would be 0xff, which is a byte that never appears in UTF-8.

Your best bet is to use a shell like bash or tcsh that puts the terminal in cbreak mode to implement its own line editing capabilities. Bash seems to bind M-Del to word erase by default. You can also run bind -P in bash to see what keys are bound to what editing functions.

  • Note that bash key bindings don't have any effect on input to other programs, unless those programs also make use of the readline library.
    – Barmar
    Jul 28, 2015 at 18:25

You must log in to answer this question.