0

I am using Evil-mode which creates a vi-layer in Emacs. This means you have different modes (e.g., NORMAL; INSERT; VISUAL). Unfortunately this also happens at times when I do not want to be in NORMAL mode. For example when an error pops up in the Cider REPL I want to be able to press q and exit the buffer immediately. Not iq (change to insert mode and quit). Same for the NeoTree navigation where I want to press ENTER to open a directory structure. Instead I have to press i ENTER (change to insert mode and open directory).

Example where I want to press ENTER on the left side, but I have to enter insert mode :

enter image description here

Is it possible to configure Emacs/Evil-mode in such a way that in the case of non text-editing Windows (like NeoTree navigation, REPL or Cider Errors) I can press the normal commands without having to switch to INSERT mode first?

2

You can assign initial states to different modes with the variables:

  • evil-emacs-state-modes
  • evil-normal-state-modes
  • evil-insert-state-modes
  • ... and so on

If you'd like to maintain the default keybindings in a certain mode without Evil getting in the way, you may wish to assign that mode to Emacs state:

(add-to-list 'evil-emacs-state-modes 'my-interesting-mode)
  • Thanks. Problem is I do want to navigate with hjkl (NORMAL mode), but ENTER should respond as in INSERT mode. – Erwin Rooijakkers Apr 15 '16 at 14:24
0

The easiest way of getting that behaviour is unbinding RET in the map where it's defined, that way Emacs will fall back to the otherwise active binding:

(eval-after-load 'evil-maps
  '(define-key evil-motion-state-map (kbd "RET") nil))

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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