Skip to content

The initial state

The initial state of a buffer is determined by its major mode. Evil maintains an association between major modes and their corresponding states, which is most easily modified using the function evil-set-initial-state.

Emacs Lisp Autofunction: (evil-set-initial-state MODE STATE)

Set the initial state for major mode `MODE' to `STATE'. This is the state the buffer comes up in.

If no state can be found, Evil uses the default initial state.

Emacs Lisp Autovariable: evil-default-state

The default Evil state. This is the state a buffer starts in when it is not otherwise configured (see evil-set-initial-state and evil-buffer-regexps). The value may be one of normal, insert, visual, replace, operator, motion and emacs.

Default: normal

Alternatively, it is possible to select the initial state based on the buffer `name' rather than its major mode. This is checked first, so it takes precedence over the other methods for setting the state.

Emacs Lisp Autovariable: evil-buffer-regexps

Regular expressions determining the initial state for a buffer. Entries have the form (REGEXP . STATE), where `REGEXP' is a regular expression matching the buffer’s name and `STATE' is one of normal, insert, visual, replace, operator, motion, emacs and nil. If `STATE' is nil, Evil is disabled in the buffer.

Default: (("^ \\*load\\*"))