添加better-default, `C-e` 未生效

Batter Default layer 中介绍,应该是可以在 vim 编辑模式下,使用 emacs 的几个快捷键,比如 C-a C-e,我添加的配置如下:

(better-defaults :variables
                 better-defaults-move-to-end-of-code-first t)

想要开启 C-e 快捷键,但是未生效,默认的 C-a 是可以的,是因为有快捷键冲突吗?我从哪里可以看到相关信息?

用C-h k C-e 查看一下与什么键冲突了。

1 个赞

设置

(better-defaults :variables
                      better-defaults-move-to-end-of-code-first t)

查看按键绑定:

C-e (

C-a

C-a是 better-default 提供的了, C-e 从上面能看出来冲突了吗?

我也遇到类似的问题,应该是被某个加载顺序靠后的minor mode的key map给覆盖掉了。。 不知道怎么解决比较好

应该是 evil 模式冲突的吧,是不是可以去设置 全局的快捷键,自己绑定 C-emwim-end-of-line-or-code 方法?

可以这样设置

(define-key evil-insert-state-map (kbd "C-e") 'mwim-end-of-code-or-line)
(define-key evil-motion-state-map (kbd "C-e") 'mwim-end-of-code-or-line)

恩,这应该算是 spacemacs 的 bug 吧。

先这样自己定义一下了。

dotspacemacs/user-config加入以下代码:

(setcdr evil-insert-state-map nil)
(define-key evil-insert-state-map [escape] 'evil-normal-state)

This layer enhances the default commands of Emacs and is primarily intended to be used with the emacs editing style as it does not change anything in the Vim key bindings.

事实上这个并没有修改 vim 模式下的键绑定。

你误解了下面这段话的意思

However the emacs editing style is not required, you can still use this layer while you are using the vim editing style if you have some kind of mixed style.

这句话是说即使你没有设置 emacs 为默认的模式,但是你经常在 emacs 和 vim 之间切换,你也可以开启这个 layer。

如果想在编辑模式下用 emacs 键绑定,开 hybird。 顺带在 hybrid 下,这个 layer 是可以在编辑模式生效的。