Last active
October 19, 2023 11:53
-
-
Save ccdunder/5816865 to your computer and use it in GitHub Desktop.
Add Emacs Evil functionality to the minibuffer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; option for enabling vi keys in the minibuffer | |
;; Addresses evil-core.el:163 TODO | |
(mapcar (lambda (keymap) | |
(evil-define-key 'insert (eval keymap) [escape] 'abort-recursive-edit) | |
(evil-define-key 'normal (eval keymap) [escape] 'abort-recursive-edit) | |
(evil-define-key 'insert (eval keymap) [return] 'exit-minibuffer) | |
(evil-define-key 'normal (eval keymap) [return] 'exit-minibuffer) | |
(evil-define-key 'insert (eval keymap) "\C-t" 'evil-normal-state) | |
) | |
;; https://www.gnu.org/software/emacs/manual/html_node/elisp/ | |
;; Text-from-Minibuffer.html#Definition of minibuffer-local-map | |
'(minibuffer-local-map | |
minibuffer-local-ns-map | |
minibuffer-local-completion-map | |
minibuffer-local-must-match-map | |
minibuffer-local-isearch-map)) | |
(add-hook 'minibuffer-setup-hook | |
'(lambda () | |
(set (make-local-variable 'evil-echo-state) nil) | |
;; (evil-set-initial-state 'mode 'insert) is the evil-proper | |
;; way to do this, but the minibuffer doesn't have a mode. | |
;; The alternative is to create a minibuffer mode (here), but | |
;; then it may conflict with other packages' if they do the same. | |
(evil-insert 1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, after quite a bit of searching and my own tries, this works like a charm! The only change I made is to retain ESC for exiting insert-mode (removing lines 5,6,9) -- these fingers are too old to learn a new binding for that.