如何让 js2-mode 在 Emacs 中使用空格而不是制表符?
-
09-06-2019 - |
题
我在用 js2模式 在 Emacs 中编辑 Javascript,但我似乎无法让它停止使用制表符而不是空格进行缩进。我的其他模式工作正常,只是遇到 js2 问题。
解决方案
你有
(setq-default indent-tabs-mode nil)
在你的 .emacs 中?当我这样做时,它在 emacs 23.0.60.1 中工作得很好。js2-mode 使用标准 emacs 函数 indent-to(它尊重 indent-tabs-mode)来进行缩进。
其他提示
将其添加到您的 .emacs
加载 js2 模式后的某个地方的文件:
(setq js2-mode-hook
'(lambda () (progn
(set-variable 'indent-tabs-mode nil))))
在我的 GNU Emacs 24.2.1 副本上,设置:
(setq-default indent-tabs-mode nil)
在 .emacs 中对于 javascript 模式来说是不够的,大概是因为该设置在每个缓冲区上下文中以某种方式被覆盖。以下更改就足够了:
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(indent-tabs-mode nil))
不隶属于 StackOverflow