如何设置 emacs 将空格更改为 TAB 字符以进行缩进?

如何设置 emacs 将空格更改为 TAB 字符以进行缩进?

我正在为 Linux 内核驱动程序编写代码。

编码标准说

The first rule that everyone needs to follow is to use the Tab character rather than spaces, to indent code. Also, the Tab character should represent eight spaces. Following along with the eight-character Tab indentation, the code should not flow past the 80 character line limit on the right of the screen.

您能告诉我如何在 emacs 中将 TAB 字符改为空格来进行缩进吗?

并使用八个字符的制表符缩进?

答案1

(setq indent-tabs-mode t)
(setq tab-stop-list (number-sequence 8 200 8))
(setq tab-width 8)
(setq indent-line-function 'insert-tab)

为了使其特定于模式,您可以执行类似的操作(只需michael-special-mode-hook用您用于编写代码的任何模式替换):

(add-hook 'michael-special-mode-hook (lambda ()
  (setq indent-tabs-mode t)
  (setq tab-stop-list (number-sequence 8 200 8))
  (setq tab-width 8)
  (setq indent-line-function 'insert-tab) ))

相关内容