Start evil mode in insert for some buffers

2019-08-02 20:32发布

问题:

I would like to set some buffers to be opened in insert mode in evil.

For example in read-only buffers there is no point in having a normal mode since i then can't use q to exit but i have to do i q. This is annoying for interactive modes that produce error buffers.

What I have been trying and failed with is as follows:

(evil-set-initial-state view-mode 'insert)

回答1:

You can modify the variable evil-insert-state-modes, which holds a list of modes that should be started in insert state:

(add-to-list 'evil-insert-state-modes 'view-mode)

There are analogous variables for emacs state, normal state, etc.