如何在 Emacs 中实现 vi 的“se ai”?

如何在 Emacs 中实现 vi 的“se ai”?

在 Emacs 中设置自动缩进的最简单方法是什么?我可以看到自动填充正确换行,例如:

  This is an indented block, and the
  wrapping happens as expected.

另一方面,我得到了这种不受欢迎的行为:

  This is an indented short line.
I'm now taken to the beginning of the
line.  I expected to be under the "T".

换句话说,我怎样才能se ai在 Emacs 中获得相当于 vi 的功能?

答案1

发布评论作为答案,以便这个问题有一个正式的答案......

简短的答案是,对于“基本模式”下的缓冲区,运行M-x electric-indent-mode

Emacs 是模式化的,每种模式都会选择适合该模式的自动缩进类型。例如,如果您编辑文本文件,您将处于“文本模式”,并且行将默认自动遵循前一行的缩进。

当 Emacs 没有找到您正在编辑的缓冲区的特殊模式时,它默认为“基本模式”。其文档字符串是:

Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one.

许多模式处理自动缩进的方式是使用称为“电子缩进模式”的次要模式(次要模式是添加到“基本模式”等主要模式的变体)。

最后,正如评论中指出的那样,Emacs 维基有更多关于缩进的信息。

相关内容