Emacs邪恶:空间作为运动状态的前缀键 [英] Emacs evil: space as a prefix key in motion state
问题描述
(define-key evil-normal-state -map(kbdSPC h)'evil-window-left)
我可以去使用邪恶领袖
...),但是这两个都不能在运动状态下做同样的事情。如果我把
(define-key evil-motion-state-map(kbdSPC h)'evil-window-左)
然后我收到错误
错误:键序列SPC h以非前缀键开始SPC
然后尝试在运动状态下定义 SPC
(define -key evil-motion-state-mapSPCnil)
但是没有摆脱的错误。
我该怎么做?我更喜欢一种仅在运动状态改变SPC的行为的解决方案。我怀疑答案在 define-prefix-command
中,但emacs维基页面令人困惑。
编辑: / p>
最上面的代码行不起作用。由于某种原因,我以为它是在正常模式下工作,但是我遇到了同样的错误。所以我可以使用邪恶的领袖,但是在运动状态下不起作用
你在正确的轨道上,尝试取消设置空格键,但 define-key
将读取SPC为 S P C ,而不是空格键。
它必须是(kbdSPC)
或(它们是等效的;前者评估为后者):
(define -key evil-motion-state-mapnil)
然后这些应该工作:
(define-key evil-motion-state-map(kbdSPC h)'邪恶窗口左)
(define-key evil-motion-state-map(kbdSPC j)'evil-window-down)
(define-key evil-motion-state-map(kbdSPC k)'evil- window-up)
(define-key evil-motion-state-map(kbdSPC l)'evil-window-right)
I want to be able to navigate windows with SPC h/j/k/l. I can just put (wrong, see edit)
(define-key evil-normal-state-map (kbd "SPC h") 'evil-window-left)
for normal state (or I could go and use evil-leader
...), but neither of these work for doing the same thing in motion state. If I put
(define-key evil-motion-state-map (kbd "SPC h") 'evil-window-left)
then I get the error
error: Key sequence SPC h starts with non-prefix key SPC
I then tried to undefine SPC
in motion state
(define-key evil-motion-state-map "SPC" nil)
but that doesn't get rid of the error.
How do I do this? I would prefer a solution that only changes the behaviour of SPC in motion state. I suspect the answer lies in define-prefix-command
but the emacs wiki page is confusing.
EDIT:
That top line of code doesn't work. For some reason I thought it was working in normal mode but I'm getting the same error. So I can go use evil-leader, but that doesn't work in motion state
You were on the right track, trying to unset the space key, but define-key
will read "SPC" as SPC, not spacebar.
It must be (kbd "SPC")
or " "
(they are equivalent; the former evaluates to the latter):
(define-key evil-motion-state-map " " nil)
Then these should work:
(define-key evil-motion-state-map (kbd "SPC h") 'evil-window-left)
(define-key evil-motion-state-map (kbd "SPC j") 'evil-window-down)
(define-key evil-motion-state-map (kbd "SPC k") 'evil-window-up)
(define-key evil-motion-state-map (kbd "SPC l") 'evil-window-right)
这篇关于Emacs邪恶:空间作为运动状态的前缀键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!