【问题标题】:Emacs Evil keybinding with evil-visual-state-map not workingEmacs Evil 与 evil-visual-state-map 的键绑定不起作用
【发布时间】:2014-09-11 14:30:11
【问题描述】:

在 Vim 中,我有这个用于导航的键绑定:noremap <M-j> 5j。这将在 normalvisualvisual line 模式下工作。

我希望在 Emacs 中具有相同的行为,所以我做到了:

(define-key evil-visual-state-map "\M-j" '(lambda () (interactive) (evil-next-line 5)))

(define-key evil-motion-state-map "\M-j" '(lambda () (interactive) (evil-next-line 5)))

它可以在normalvisual模式下工作,但不能在visual line模式下工作(即大写V强>)。

我是来自 Vim 的 Emacs 新手。

【问题讨论】:

    标签: vim emacs


    【解决方案1】:

    查看源代码,让我们这样做:

    (evil-define-motion myevil-next-visual-line (count)
    "Move the cursor COUNT screen lines down, or 5."
    :type exclusive
      (let ((line-move-visual t))
      (evil-line-move (or count 5))))
    

    (define-key evil-visual-state-map "\M-j" 'myevil-next-visual-line)
    

    【讨论】:

    【解决方案2】:

    如果你有

    (defun godown() (interactive) (evil-next-line 5)) (define-key evil-visual-state-map "\M-j" 'godown)

    然后你可以做任何只是添加

    (evil-declare-motion 'godown)

    或者你可以使用

    (evil-define-motion godown () (interactive) ... )

    替换defun + evil-declare-motion 组合。

    来源:https://bitbucket.org/lyro/evil/issues/395/cant-use-evil-next-line-in-a-script-in-a

    【讨论】:

      猜你喜欢
      • 2014-09-29
      • 2012-10-06
      • 1970-01-01
      • 2014-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-05
      • 1970-01-01
      相关资源
      最近更新 更多