Created
February 11, 2011 17:50
-
-
Save timcharper/822738 to your computer and use it in GitHub Desktop.
In vimpule mode, allow "jk" sequence to switch back to viper mode... there may be an fn that already implements this... but this works:
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
(defun viper-escape-if-next-char (c) | |
"Watches the next letter. If c, then switch to viper mode, otherwise insert a j and forward unpressed key to unread-command-events" | |
(self-insert-command 1) | |
(let ((next-key (read-event))) | |
(if (= c next-key) | |
(progn | |
(delete-backward-char 1) | |
(viper-mode)) | |
(setq unread-command-events (list next-key))))) | |
(defun viper-escape-if-next-char-is-k (arg) | |
(interactive "p") | |
(if (= arg 1) | |
(viper-escape-if-next-char ?k) | |
(self-insert-command arg))) | |
(define-key viper-insert-basic-map (kbd "j") 'viper-escape-if-next-char-is-k) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment