Skip to content

Instantly share code, notes, and snippets.

@alesya-h
Created January 3, 2012 11:46
Show Gist options
  • Save alesya-h/1554613 to your computer and use it in GitHub Desktop.
Save alesya-h/1554613 to your computer and use it in GitHub Desktop.
type jk in insert mode to switch to normal mode (for emacs-evil)
(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)
@jdhao
Copy link

jdhao commented Oct 12, 2021

It works, but we can not insert jk literally anymore, which is not satisfactory.

@jdhao
Copy link

jdhao commented Oct 12, 2021

A better solution is this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment