当然,在 emacs 中一切皆有可能:)
将这段代码添加到您的配置中。
(add-hook 'evil-mode-hook 'evil-mode-bindings)
(defun evil-mode-bindings ()
"Bind symbols to digits."
(define-key key-translation-map (kbd "!") (kbd "1"))
(define-key key-translation-map (kbd "@") (kbd "2"))
(define-key key-translation-map (kbd "#") (kbd "3"))
(define-key key-translation-map (kbd "$") (kbd "4"))
(define-key key-translation-map (kbd "%") (kbd "5"))
(define-key key-translation-map (kbd "^") (kbd "6"))
(define-key key-translation-map (kbd "&") (kbd "7"))
(define-key key-translation-map (kbd "*") (kbd "8"))
(define-key key-translation-map (kbd "(") (kbd "9"))
(define-key key-translation-map (kbd ")") (kbd "0")))
每当您进入邪恶模式时,evil-mode-hook
都会运行evil-mode-bindings
功能。此函数将符号绑定到相应的数字。
更新:
正如@npostavs 提到的,您也可以使用它
(add-hook 'evil-mode-hook 'evil-mode-bindings)
(defun evil-mode-bindings ()
"Bind symbols to digits."
(define-key key-translation-map (kbd "!") "1")
(define-key key-translation-map (kbd "@") "2")
(define-key key-translation-map (kbd "#") "3")
(define-key key-translation-map (kbd "$") "4")
(define-key key-translation-map (kbd "%") "5")
(define-key key-translation-map (kbd "^") "6")
(define-key key-translation-map (kbd "&") "7")
(define-key key-translation-map (kbd "*") "8")
(define-key key-translation-map (kbd "(") "9")
(define-key key-translation-map (kbd ")") "0"))