Let's be Evil (vim like emacs)

This commit is contained in:
2026-01-03 18:09:57 +01:00
parent 996377775c
commit 03be810a0d
+103
View File
@@ -454,3 +454,106 @@ Customizing faces.
#+end_src
* Keyboard bindings
** ESC cancels all
#+begin_src emacs-lisp
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
#+end_src
** Let's Be Evil
Some tips can be found here:
- [[https://github.com/noctuid/evil-guide][Evil guide]]
- [[https://nathantypanski.com/blog/2014-08-03-a-vim-like-emacs-config.html][Vim like Emacs config]]
#+begin_src emacs-lisp
(setup (:straight undo-tree)
(setq undo-tree-auto-save-history nil)
(global-undo-tree-mode 1))
(setup (:straight goto-chg))
(setup (:straight evil)
;; Pre-load configuration
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
(setq evil-want-C-u-scroll t)
(setq evil-want-C-i-jump nil)
(setq evil-respect-visual-line-mode t)
(setq evil-undo-system 'undo-tree)
;; Activate the Evil
(evil-mode 1)
;; Set Emacs state modes
(dolist (mode '(custom-mode
eshell-mode
git-rebase-mode
erc-mode
circe-server-mode
circe-chat-mode
circe-query-mode
sauron-mode
term-mode))
(add-to-list 'evil-emacs-state-modes mode))
(define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state)
(define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join)
;; Use visual line motions even outside of visual-line-mode buffers
(evil-global-set-key 'motion "j" 'evil-next-visual-line)
(evil-global-set-key 'motion "k" 'evil-previous-visual-line)
(evil-set-initial-state 'messages-buffer-mode 'normal)
(evil-set-initial-state 'dashboard-mode 'normal))
(setup (:pkg evil-collection)
;; Is this a bug in evil-collection?
(setq evil-collection-company-use-tng nil)
(:load-after evil
(:option evil-collection-outline-bind-tab-p nil
(remove evil-collection-mode-list) 'lispy
(remove evil-collection-mode-list) 'org-present)
(evil-collection-init)))
#+end_src
** Keybinding Panel (which-key)
[[https://github.com/justbur/emacs-which-key][which-key]] is great for getting an overview of what keybindings are available
based on the prefix keys you entered. Learned about this one from Spacemacs.
#+begin_src emacs-lisp
(setup (:pkg which-key)
(:load-after diminish
(diminish 'which-key-mode)
(which-key-mode)
(setq which-key-idle-delay 0.3)))
#+end_src
** Simplify leader bindings (general.el)
[[https://github.com/noctuid/general.el][general.el]] is a fantastic library for defining prefixed keybindings, especially
in conjunction with Evil modes.
#+begin_src emacs-lisp
(setup (:pkg general)
(general-evil-setup t)
(general-create-definer mr/leader-key
:keymaps '(normal insert visual emacs)
:prefix "SPC"
:global-prefix "C-SPC")
(general-create-definer mr/ctrl-c-keys
:prefix "C-c"))
#+end_src