Initially I naively shared the answer below which not only it doesn't work (since it "disables" j
and k
) but also many emacs folks would laugh!
I found that evil-mode
provides evil-define-key
according to https://evil.readthedocs.io/en/latest/keymaps.html#evil-define-key.
So I tried below and it works for me.
;; you should be able to do "jj" instead but I prefer "jk"
(evil-define-key 'insert 'global (kbd "jk") 'evil-normal-state)
Now I found a real answer that is satisfying to me and working (using https://github.com/noctuid/general.el)
;; Enable installation of packages from MELPA.
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
;; Download Evil
(unless (package-installed-p 'evil)
(package-install 'evil))
;; Enable Evil
(require 'evil)
(evil-mode 1)
;; ------------------------------------------------------
;; you might have all the above already
;; but I still included for the completeness of the code
;; ------------------------------------------------------
;; Download general.el
(unless (package-installed-p 'general)
(package-install 'general))
;; Enable general.el
(require 'general)
(general-evil-setup)
;; now usable `jk` is possible!
(general-imap "j"
(general-key-dispatch 'self-insert-command
:timeout 0.25
"k" 'evil-normal-state))
since I literally just discovered general.el
, this code might not be optimal