Useful Emacs/Evil Keybindings

I am a big fan of Emacs. In particular, I use the Spacemacs pre-configuration. However, one thing that bugged me about the defaults is that C-h and C-w don’t map to backspace and backward-word-kill (respectively). One thing I tried was the following:

(global-set-key "\C-h" 'backward-delete-char)
(global-set-key "\C-w" 'evil-delete-backward-word)

Note that I use evil-delete-backward-word rather than the usual backward-word-kill, as (for my purposes) they are equivalent.

But this misses a few modes, in particular in helm and isearch modes. As a result, I have accumulated a list of these additional modes that need these keybinds.

Here is the full list. Hopefully, it is useful to you if you came across this article:

(global-set-key "\C-h" 'backward-delete-char)
(global-set-key "\C-w" 'evil-delete-backward-word)
(define-key helm-map "\C-h" 'delete-backward-char)
(define-key helm-map "\C-w" 'evil-delete-backward-word)
(define-key helm-find-files-map "\C-w" 'evil-delete-backward-word)
(define-key iedit-mode-keymap "\C-h" 'backward-delete-char)
(define-key iedit-mode-occurrence-keymap "\C-h" 'backward-delete-char)
(define-key isearch-mode-map "\C-h" 'backward-delete-char)
(define-key isearch-mode-map "\C-w" 'evil-delete-backward-word)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: