reddit / emacs

How can I switch a vterm window to evil insert mode after it is created?

vfclists · 2022-04-11 02:35
This is the code I am trying. (use-package vterm :load-path "site-lisp/emacs-libvterm/" :config (evil-insert-state) ) Should I be using some hook instead?
yep808 · 2022-04-11 03:57
Try this (under :config) ``` (with-eval-after-load 'evil (evil-set-initial-state 'vterm-mode 'insert)) ``` Instead of **'insert**, I recommend using this **'emacs** though, so it aligns with the default keybindings in bash/zsh, which is emacs-style.
vfclists · 2022-04-11 16:31
Thanks. That hit the spot. Can you explain what the code does, especially the meaning of the leading single quotes? Another question - according to the `use-package` docs `:config` runs after the package has been loaded. Isn't that equivalent to `with-eval-after-load`? Perhaps I've got the place of `config` in the package loading sequence wrong.
yep808 · 2022-04-11 16:50
For the meaning of quotes, try reading up on some beginner elisp manuals. You could start here: [https://www.gnu.org/software/emacs/manual/html\_node/elisp/Quoting.html](https://www.gnu.org/software/emacs/manual/html_node/elisp/Quoting.html) You're right that :config runs after the package loads, but in your context it only runs after "vterm" is loaded (because you're putting the code in a vterm use-package block), not evil (at least not guaranteed). For evil-set-insert-state to be defined at the time of using, the safe way is to wrap it around a with-eval-after-load. An alternative way is to use ":after evil" in your vterm use-package block.