How to change indentation in text-mode for emacs

爱⌒轻易说出口 提交于 2019-12-03 13:07:58
Jérôme Radix

Add this to your .emacs :

(add-hook 'text-mode-hook
          '(lambda ()
             (setq indent-tabs-mode nil)
             (setq tab-width 2)
             (setq indent-line-function (quote insert-tab))))

See Emacs Indentation Tutorial.

jwernerny

The default for in text-mode will indent to the first non-whitespace character in the line above it.

From the key binding documentation in text mode

TAB (translated from ) runs the command indent-for-tab-command, which is an interactive compiled Lisp function in `indent.el'.

It is bound to TAB.

(indent-for-tab-command &optional ARG)

Indent line or region in proper way for current major mode or insert a tab. Depending on `tab-always-indent', either insert a tab or indent.

In most major modes, if point was in the current line's indentation, it is moved to the first non-whitespace character after indenting; otherwise it stays at the same position in the text....

Luckily, this can be changed. Adding the following to your text-mode-hook should do what you need:

(setq tab-width 2)
(setq indent-line-function (quote insert-tab))
ocodo

Try setting

(setq standard-indent 2)

In your .emacs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!