I want to redefine C-w to run one of my commands. evil has already defined a number of key sequences that start with C-w to run its commands. So my command does not run, Emacs just waits for me to complete the sequence.

Is there a way I can undefine all existing sequences starting with C-w so that Emacs will then run my C-w command?


2 Answers 2


By default, evil binds C-w to the evil-window-map, within which it stores the rest of the keybindings.

In looking at the source code, the core spot it happens is in evil-motion-state-map. Depending on how you set evil-want-C-w-delete and evil-want-C-w-in-emacs-state, it will also bind the key in evil-insert-state-map and evil-emacs-state-map as well.

You can undefine the key with:

(define-key evil-motion-state-map "\C-w" nil)

and, if necessary, with:

(define-key evil-insert-state-map "\C-w" nil)
(define-key evil-emacs-state-map  "\C-w" nil)

You can now bind a different key combination to evil-windows-map. Here's an uncomfortable example, but you get the point:

(define-key evil-motion-state-map "\C-!" 'evil-windows-map)
  • Fantastic, thank you. So it seems Evil does funky things with key bindings that need to be handled via Evil. I will bear that in mind. Jul 19, 2016 at 13:17

If your C-w command is shadowed by evil-mode, the following undefine evil's C-w command.

(define-key evil-motion-state-map (kbd "C-w") nil)

If you want to use C-w command even on insert-state of evil-mode, you should evaluate the following.

(define-key evil-insert-state-map (kbd "C-w") nil)   
  • Please explain how this post is not a duplicate of the other answer.
    – Dan
    Jul 19, 2016 at 13:51
  • Sorry, while I wrote this answer, you posted your answer. I didn't imitate your answer. Your answer is more detailed, so I will also refer to your answer.
    – hewld
    Jul 25, 2016 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.