I am trying to extend evil-like conventions to comint mode so I can use vim-like key bindings from the shell. I also rebound C-c to #'evil-normal-state since that is what I use in vim (it isn't strictly equivalent to C-[ but I haven't run into the weird edge cases where that actually matters yet).

I am using the evil-define-key macro to define comint-mode-specific bindings in normal state that begin with SPC f and so far that works great.

However, all the mode-specific key bindings beginning with C-c are still there despite the fact that C-c is bound to #'evil-normal-state in every state. I don't want to globally rebind C-c since that would interfere with emacs state.

What is the cleanest way to prevent comint-mode from defining any additional key bindings at all since evil-mode is effectively managing all the keys?

I have tried adding

(setf comint-mode-map (make-keymap))


(setf comint-mode-map (make-sparse-keymap))

to my .emacs file, but whenever I type M-x shell, I get the error

Wrong type argument: keymapp, 1
  • 1
    Some unsolicited advice: emacs uses the C-c prefix for a huge range of things, so you're going to be cutting yourself off from a lot of functionality (absent a lot of manual rebinding on your part) if you choose to take over C-c in this way. Just about any other key (other than C-x or M-x) would probably be a less hassle-filled long-run choice.
    – Dan
    Jan 3, 2016 at 20:54
  • If C-c is re-mapped only in the insert state it is no problem it will still keep original bindings in the normal state.
    – Arktik
    Apr 14, 2020 at 21:12

1 Answer 1


If that's really what you want to do, do it on comint-mode-hook:

(add-hook 'comint-mode-hook (lambda () (setq comint-mode-map (make-sparse-keymap))))

You are probably getting that error because the comint code itself tries to bind keys on the prefix key C-c, but you have removed that.

  • I tried emacs -Q -l patch-comint-mode-hook.el with that just snippet. Inside the M-x shell-shell the C-c commands are still there. Jan 3, 2016 at 20:42
  • Try doing the same for shell-mode-hook, as well.
    – Drew
    Jan 3, 2016 at 20:46
  • patching the mode hooks for both comint mode and shell mode does not appear to suppress the keybindings. I used the following as my init file: (add-hook 'comint-mode-hook (lambda () (setq comint-mode-map (make-sparse-keymap)))) (add-hook 'shell-mode-hook (lambda () (setq shell-mode-map (make-sparse-keymap)))) Jan 3, 2016 at 21:19

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.