Reputation: 53
I'm aware of evil-escape-sequence
but from what I can tell, you can only have one keybinding set to it. I want fd
and jh
both to bring me to Normal state from Insert state.
I've also tried something like (map! :i "jh" #'evil-normal-mode)
but with this, whenever I type j
, Emacs freezes and waits for me to complete the command.
Upvotes: 5
Views: 3991
Reputation: 21
If you do not want to use key-chord, there is another way:
(defun evil-insert-jk-for-normal-mode ()
(interactive)
(insert "j")
(let ((event (read-event nil)))
(if (= event ?k)
(progn
(backward-delete-char 1)
(evil-normal-state))
(push event unread-command-events))))
(define-key evil-insert-state-map "j" 'evil-insert-jk-for-normal-mode)
(Tested in doom-emacs v3.0.0-alpha.)
Upvotes: 0
Reputation: 95
For doom emacs ,
In package.el
as opened by spc-f-p
put
(package! key-chord)
to install package.
to remap i found this helpful https://stackoverflow.com/a/13543550/14183927
Upvotes: 0
Reputation: 330
I have done this with the keychord package. Note, this package measures the timeframe between the keystrokes in order to determine wether to trigger the paired function. This is how you can use h, j, k, l
(keys that map to navigation in normal mode) for this extra functionality.
Add (package! key-chord)
to 'init.el' and the following code to 'config.el'.
(require 'key-chord)
(key-chord-mode t)
(key-chord-define-global "fd" 'evil-normal-state)
(key-chord-define-global "FD" 'evil-normal-state)
(key-chord-define-global "jh" 'evil-normal-state)
(key-chord-define-global "JH" 'evil-normal-state)
I added the capitalized equivalent so that you have the same functionality even when the caps lock is on.
Upvotes: 4