设置 org-special-ctrl-a/e 变量解决在org标题中的行首问题

在 org-mode 使用中,遇到这样一个问题,如果是在标题行,想回到行首,如果此时按 HOME 键,或 (org-beginning-of-line) 光标会跳到 “*” 前,这自然和我们想要的结果是不一样的。

在 emacs-china 询问了相关网友后,VagrantJoker 给出了正解的解决方案,即设置 org-special-ctrl-a/e 变量的值到 t 即可。变量说明如下:

Documentation Non-nil means C-a and C-e behave specially in headlines and items.

When t, C-a will bring back the cursor to the beginning of the headline text, i.e. after the stars and after a possible TODO keyword. In an item, this will be the position after bullet and check-box, if any. When the cursor is already at that position, another C-a will bring it to the beginning of the line.

C-e will jump to the end of the headline, ignoring the presence of tags in the headline. A second C-e will then jump to the true end of the line, after any tags. This also means that, when this variable is non-nil, C-e also will never jump beyond the end of the heading of a folded section, i.e. not after the ellipses.

When set to the symbol reversed, the first C-a or C-e works normally, going to the true line boundary first. Only a directly following, identical keypress will bring the cursor to the special positions.

This may also be a cons cell where the behavior for C-a and C-e is set separately.

大意是当设置为 t 之后,按行首键时,光标会移动到标题的第一个字前,而不是”*“号前,行尾会移动到标题的最后一个字后,而不是tag后。

海上一民工

Related