Emacs で js2-mode でタブの代わりにスペースを使用できるようにするにはどうすればよいですか?

StackOverflow https://stackoverflow.com/questions/45861

質問

使っています js2モード Emacs で Javascript を編集したいのですが、インデントにスペースの代わりにタブを使用するのをやめることができないようです。他のモードは正常に動作しますが、js2 に問題があるだけです。

役に立ちましたか?

解決

持っていますか

(setq-default indent-tabs-mode nil)

.emacs の中で?これを行うと、emacs 23.0.60.1 では正常に動作します。js2-mode は、indent-tabs-mode を尊重する標準 emacs 関数 indent-to を使用してインデントを行います。

他のヒント

これを .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))
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top