繁体   English   中英

如何在Emacs中使用js2-mode来使用空格而不是制表符?

[英]How do I get js2-mode to use spaces instead of tabs in Emacs?

我正在使用js2-mode来编辑Emacs中的Javascript,但我似乎无法让它停止使用制表符而不是空格来缩进。 我的其他模式工作正常,只有问题w / js2。

你有没有

(setq-default indent-tabs-mode nil)

在你的.emacs? 当我这样做时,它在emacs 23.0.60.1中对我很好。 js2-mode使用标准的emacs函数indent-to,它遵循indent-tabs-mode来进行缩进。

加载js2模式后,将其添加到您的.emacs文件中:

(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))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM