zl程序教程

您现在的位置是:首页 >  Java

当前栏目

解决 evil 模式下,TAB 在 org-mode 失效的问题

2023-02-18 16:29:03 时间

在 Org 中,TAB 被绑定在了 org-cycle ,可以非常方便的对某个标题下的内容折叠/展开,但是在 evil 的 normal 模式下,TAB 则被覆盖成了 evil-jump-forward ,这其实是和 Vim 对应的[1]

  • Ctrl-i jump forward to the next (newer) location.
  • Ctrl-o to jump back to the previous (older) location.

同时,又由于在终端中, TAB 与 C-i 发送的是相同的 keycode 9(即 Character Tabulation[2]),所以导致了上面的行为。

由于笔者大多数不会用到 evil 的 jump 功能,所以一种简单的修复就是直接关闭它:

(setq evil-want-C-i-jump nil)

注意一点:这个初始化需要在加载 evil 前执行。如果使用 use-package 可以使用下面的方式:

(use-package evil
  :custom ((evil-want-C-i-jump nil))
  :config (evil-mode))

如果希望保留 evil 的 jump 功能,可以尝试把 TAB 与 C-i 区分开

  • • key bindings - How to distinguish C-i from TAB? - Emacs Stack Exchange[3]
  • • https://emacs.stackexchange.com/a/20290/16450

参考

  • • “Fix” the tab key for visibility cycling in Org and Evil mode[4]

引用链接

[1] Vim 对应的: https://zhuanlan.zhihu.com/p/270989474 [2] Character Tabulation: https://en.wikipedia.org/wiki/Tab_key [3] key bindings - How to distinguish C-i from TAB? - Emacs Stack Exchange: https://emacs.stackexchange.com/questions/17509/how-to-distinguish-c-i-from-tab [4] “Fix” the tab key for visibility cycling in Org and Evil mode: https://jeffkreeftmeijer.com/emacs-evil-org-tab/