How to bind Emacs key for delete whole word backword as the same in a shell?

I have just started learning Linux and Emacs. It was pleasant to have the same key bindings in both Emacs and a shell (bash/tcsh) for the most frequently used cursor movements, so that I do not have to consciously think which one I have to use. Still worse, use the wrong command and undo the mistake. There were two exceptions, though.

One often used command was the equivalent of backspace, delete a character backwards. In a shell, it was C-h. I got the same behaviour in Emacs, thanks to this tip from Janos, who probably felt the same way. http://www.math.rutgers.edu/~komlos/emacs.htm

Now the mistake I do often in Emacs is trying to delete words backwards with the command M-C-h, as in a shell.

Can somebody please give a binding that will make Emacs delete words backwards with 'M-C-h'? Currently, this command selects the whole of the text in a buffer, which is quite an useful thing (C-a in windows), but not so frequently used as deleting words backwards.

Moreover, any binding to replace the current binding of M-h (from the link above) to help will be appreciated.

Thank you,

Elan.

Answers


Below binds C-M h to backward-kill-word. You can put it in your .emacs file.

(global-set-key (kbd "C-M-h") 'backward-kill-word)

You can use M-<backspace> in terminal and emacs to delete word backward.


It's best to use key translation so C-M-h works exactly the same as M-backspace would in any minor mode (regardless of whether M-backspace is bound to backward-kill-word or not).

;; bind C-h to <backspace>
(define-key key-translation-map [?\C-h] [?\C-?])
;; bind C-M-h to M-<backspace>
(define-key key-translation-map [?\C-\M-h] [?\C-\M-?])

Need Your Help

Python Tk (Tkinter) not work transparency on ubuntu unity

python tkinter tk

This code in python 2.7.3 work in windows xp, not work in Ubuntu Unity.

issue with meta data in android studio

android google-maps

Hi guys I've already try all the tutorials found here and in the developers site and I can't mannage to find the answer to my issue... ok I'm trying to make a simple app that render a map using gma...