无法重新映射邪恶的键绑定

Unable to remap evil key bindings

我是 emacs 的新手,我一直在尝试重新映射邪恶模式中的一些键。我一直在尝试重新映射用于在 windows 之间切换的键,但到目前为止我没有运气。

(use-package evil
   :config 
   (evil-mode 1)

   (define-key evil-motion-state-map (kbd "C-j") 'evil-window-down)
   (define-key evil-motion-state-map (kbd "C-k") 'evil-window-up)
   (define-key evil-motion-state-map (kbd "C-l") 'evil-window-right)
   (define-key evil-motion-state-map (kbd "C-h") 'evil-window-left))

尝试绑定。

(use-package evil
  :bind (:map evil-motion-state-map
              ("C-j" . evil-window-down)
              ("C-k" . evil-window-up)
              ("C-l" . evil-window-right)
              ("C-h" . evil-window-left)))

更新:

(use-package evil
:bind ((:map evil-window-map
             ("C-j" . evil-window-down)
             ("C-k" . evil-window-up)
             ("C-l" . evil-window-right)
             ("C-h" . evil-window-left))
       (:map evil-normal-state-map
             ("C-j" . evil-window-down)
             ("C-k" . evil-window-up)
             ("C-l" . evil-window-right)
             ("C-h" . evil-window-left)))
:config (evil-mode 1))

我是这样解决的:

(defun evil()

  (require 'evil)
  (define-key global-map (kbd "C-h") nil)
  (define-key global-map (kbd "C-j") nil)
  (define-key global-map (kbd "C-k") nil)
  (define-key global-map (kbd "C-l") nil)

  (global-set-key (kbd "C-h") 'evil-window-left)
  (global-set-key (kbd "C-j") 'evil-window-down)
  (global-set-key (kbd "C-k") 'evil-window-top)
  (global-set-key (kbd "C-l") 'evil-window-right)

  (evil-mode 1))

您也可以使用 use-package 而不是 require