dotfiles/emacs-lisp/evil.org
main c1dc0c1d7f
Move keybindings related Emacs config to separate file
Signed-off-by: main <magic_rb@redalder.org>
2022-04-15 09:50:18 +02:00

54 lines
1.5 KiB
Org Mode

:PROPERTIES:
:ID: f941f57a-d3fc-4b4b-ac85-2ff69ef942e5
:ROAM_REFS: https://github.com/emacs-evil/evil
:END:
#+title: Evil Mode
#+filetags: emacs-load
#+BEGIN_QUOTE
Evil is an extensible vi layer for Emacs. It emulates the main features of Vim, and provides facilities for writing custom extensions.
#+END_QUOTE
#+BEGIN_NOTE
This requires ~general.el~.
#+END_NOTE
#+BEGIN_SRC emacs-lisp
(use-package evil
:straight t
:init
(setq evil-want-keybinding nil)
:config
(setq evil-respect-visual-line-mode t)
(evil-mode)
;; :q should kill the current buffer rather than quitting emacs entirely
(evil-ex-define-cmd "q" 'kill-this-buffer)
;; Need to type out :quit to close emacs
(evil-ex-define-cmd "quit" 'evil-quit)
;; save and close buffer
(defun liu233w/ex-save-kill-buffer-and-close ()
(interactive)
(save-buffer)
(kill-this-buffer))
(evil-ex-define-cmd "wq" 'liu233w/ex-save-kill-buffer-and-close))
(use-package evil-collection
:straight t
:after (evil vterm)
:config
(evil-collection-init 'vterm)
(defun evil-collection-vterm-escape-stay ()
"Go back to normal state but don't move cursor backwards.
Moving cursor backwards is the default vim behavior but
it is not appropriate in some cases like terminals."
(setq-local evil-move-cursor-back nil))
(add-hook 'vterm-mode-hook #'evil-collection-vterm-escape-stay))
(use-package evil-surround
:straight t
:after evil
:config
(global-evil-surround-mode 1))
#+END_SRC