[英]Emacs JavaScript auto-indentation
I'm looking for a way to turn off automatic indentation in emacs. 我正在寻找一种方法来关闭emacs中的自动缩进。 I don't want emacs to automatically indent code when I enter special characters like ;
当我输入特殊字符时,我不希望emacs自动缩进代码; or /*
要么 /*
Thanks for any help. 谢谢你的帮助。
Steve Yegge's js2-mode is great. Steve Yegge的js2模式很棒。
From http://code.google.com/p/js2-mode/ 来自http://code.google.com/p/js2-mode/
An improved JavaScript mode for GNU Emacs. GNU Emacs的改进JavaScript模式。
Features: 特征:
Eventually aims to be competitive with IntelliJ and other best-of-class JavaScript editors. 最终旨在与IntelliJ和其他一流的JavaScript编辑器竞争。
Note - this mode is for GNU Emacs, version 21 and higher. 注意 - 此模式适用于GNU Emacs,版本21及更高版本。 It does not support XEmacs.
它不支持XEmacs。
If you're using an old mode based on CC-mode, Cc Cl
will toggle electricity. 如果您使用基于CC模式的旧模式,
Cc Cl
将切换电力。
There's a new Javascript mode that ships with Emacs that can be interactively toggled with Mx electric-indent-mode
Emacs附带了一个新的Javascript模式,可以通过
Mx electric-indent-mode
进行交互式切换
Apparently, the new blessed way to achieve this is: 显然,实现这一目标的新方法是:
M-x electric-indent-mode
This command toggles "electric indentation", ie auto-indenting whenever certain special characters are hit. 此命令切换“电子缩进”,即每当遇到某些特殊字符时自动缩进。
The best thing is that it works accross major modes, not only for js-mode
(the default javascript major mode in recent version of Emacs). 最好的是它适用于主要模式,不仅适用于
js-mode
(最近版本的Emacs中的默认javascript主模式)。
Set javascript-auto-indent-flag
to nil
before loading javascript-mode. 在加载javascript-mode之前将
javascript-auto-indent-flag
为nil
。 You can either add a line to your .emacs
file or type 您可以在
.emacs
文件中添加一行或输入
M-x customize-group RET javascript RET
and edit the value there and save. 并在那里编辑值并保存。 You may need to restart Emacs for this to take effect;
您可能需要重新启动Emacs才能生效; at least in the version of
javascript.el
that I have, the flag is only consulted when setting up the keymap. 至少在我所拥有的
javascript.el
版本中,只有在设置keymap时才会查询该标志。
这将关闭所有缩进: Mx基本模式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.