I have a freshly installed spacemacs installation and I want to make it so that I ansi-term is in emacs mode. However, I try to add

(add-to-list 'evil-emacs-state-modes 'term-mode)

to my .spacemacs in the dotspacemacs/user-config and/or dotspacemacs/user-init function and it has no effect.

Is there a canonical way to do this in spacemacs?

2 Answers 2


You can use this snippet in your dotspacemacs/user-config function:

(evil-set-initial-state 'term-mode 'emacs)
  • I assume you mean dotspacemacs/user-config? I have no dospacemacs/user-configuration. Commented Feb 2, 2016 at 16:35

Disclaimer: I assume this is in no way related to Spacemacs.

The evil-emacs-state-modes variable is initialized with a list of modes to start in Emacs state. This is a mishap as it makes it harder to customize it properly, any successful change to the variable will not take this value into account and Evil's code will not change it either because the variable is defined and initialized by then. In your example, nothing happens as add-to-list does only do something if the variable has already been defined. You can circumvent this by using a hook run after the package has been loaded up or with eval-after-load:

(eval-after-load 'evil-vars '(add-to-list 'evil-emacs-state-modes 'term-mode))

The official way of changing that list though is via evil-set-initial-state:

(eval-after-load 'evil-vars '(evil-set-initial-state 'term-mode 'emacs))
  • Great, this worked after putting it in the dotspacemacs/user-config (not dotspacemacs/user-init since I think spacemacs overrides the behaviour there) Commented Feb 2, 2016 at 11:49

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.