将转义键绑定到邪恶模式的键盘

时间:2013-10-03 02:55:05

标签: emacs evil-mode

我从emacs网站上获取了以下代码以供恶意使用 -

(defun my-esc (prompt)
  "Functionality for escaping generally.  Includes exiting Evil insert state and C-g binding. "
  (cond
   ;; If we're in one of the Evil states that defines [escape] key, return [escape] so as
   ;; Key Lookup will use it.
   ((or (evil-insert-state-p) (evil-normal-state-p) (evil-replace-state-p) (evil-visual-state-p)) [escape])
   ;; This is the best way I could infer for now to have C-c work during evil-read-key.
   ;; Note: As long as I return [escape] in normal-state, I don't need this.
   ;;((eq overriding-terminal-local-map evil-read-key-map) (keyboard-quit) (kbd ""))
   (t (kbd "C-g"))))
(define-key key-translation-map (kbd "C-c") 'my-esc)
;; Works around the fact that Evil uses read-event directly when in operator state, which
;; doesn't use the key-translation-map.
(define-key evil-operator-state-map (kbd "C-c") 'keyboard-quit)
;; Not sure what behavior this changes, but might as well set it, seeing the Elisp manual's
;; documentation of it.
(set-quit-char "C-c")

设置C-c键以退出插入模式。如何将其更改为更方便的键盘,例如“tt”?

我使用了以下 -

  

(key-chord-define evil-insert-state-map“tt”'evil-normal-state)

但是当我在插入模式下按'tt'时,它会在迷你缓冲区中提供以下信息 -

<key-chord> <escape> is undefined

1 个答案:

答案 0 :(得分:3)

我无法重现您的错误,对我来说很好。 确保安装了和弦包。

(require 'key-chord)(key-chord-mode 1) ; turn on key-chord-mode
(key-chord-define evil-insert-state-map "tt" 'evil-normal-state)