Followup on Mac OS X Terminal: Map option+delete to “backward delete word”.

The Use option key as meta key option is checked, but the deleting word backwards works only with ^--H (i.e. one has to also hold the ^ or Control key)! How can you backward delete a word with -H only? This annoyance happens only in Terminal.app ... and interestingly also in iTerm.app!

I also have this in ~/Library/KeyBindings/DefaultKeyBinding.dict, so that I can enjoy Emacs throughout:

{"~h" = "deleteWordBackward:";}

Environment: OS X 10.8.2 (12C54), Terminal 2.3 (309), iTerm

  • 1
    On OS X 10.8.4, when I type Option-H with “Option is Meta” enabled, it sends “ESC h”. What program are you interacting with? Are you sure it maps “ESC h” to “backward delete word”? In many programs, you can verify what’s being sent to the tty by prefixing with either Control-V or Control-Q to quote the “ESC h” input.
    – Chris Page
    Sep 11 '13 at 12:34
  • For questions like this, it helps to include the OS version you’re working with.
    – Chris Page
    Sep 11 '13 at 13:39
  • @Chris Nice tip on using Control-V for inspection. Pressing "Option-H" sends "^[h" (either Option_L or Option_R).
    – Blaz
    Sep 11 '13 at 13:55
  • Do you want to use Option + H or would Option + Delete be fine for the same purpose?
    – M K
    Sep 11 '13 at 13:58
  • @MK Option + H, of course. Must stay on the home row. :)
    – Blaz
    Sep 11 '13 at 14:02

Settings in DefaultKeyBinding.dict don't apply to the shell views in Terminal or iTerm 2.

You can make M-h delete a word backward by adding this to ~/.inputrc

"\eh": backward-kill-word

M-h is bound to mark-paragraph by default in Emacs though.

If others search for how to make ⌥⌫ delete a word backward, just enable using option as a meta key:

  • In Terminal, check Settings > (your profile) > Keyboard > Use option as meta key
  • In iTerm 2, set the option keys to act as "+ Esc" in Profiles > (your profile) > Keys

If others search for how to make ⌥⌦ delete a word forward, you can make it insert \ed:

⌥⌦ inserts \e( by default in Terminal and \e[3~ in iTerm 2, so you could also add "\e(": kill-word or "\e[3~": kill-word to ~/.inputrc.


Almost all terminal use emacs hotkeys to manipulate text (see readline keyboard shortcuts), and in emacs, you use backward-kill-word (meta-delete) to delete the previous word.

And, in emacs, meta-<KEY> (key composition) equals to escape <KEY> (key chord), so in this case, you can use ESCAPE DEL to delete the previous word.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .