在 Emacs 中全局禁用自动缩进 [英] Disable auto indent globally in Emacs
问题描述
如何在 Emacs 中全局或仅对某些模式禁用自动缩进?
How to disable auto indent in Emacs globally or only for some modes?
我为 RubyOnRails 安装了许多软件包(ruby、html、js、css).
I have a number of packages installed for RubyOnRails (ruby, html, js, css).
假设我想为 css 模式禁用自动缩进.
Let's say I want to disable autoindent for css-mode.
推荐答案
您可能想要查找包含单词 electric
的变量名称.(这是 Emacs 的常用说法,用于在键入特定可见字符时自动发生的操作.)
You may want to look for variable names containing the word electric
. (This is the common Emacs parlance for actions which occur automatically when particular visible characters are typed.)
在这种情况下,Mx apropos-variable
RET electric
RET 显示我知道有一个 css-electric-keys
变量包含一个应该触发重新缩进的自插入键"列表.
In this instance, M-x apropos-variable
RET electric
RET shows me that there is a css-electric-keys
variable containing a list of "Self inserting keys which should trigger re-indentation."
你可以使用 Mx customize-variable
RET css-electric-keys
RET 将此列表设置为 nil,或将 (setq css-electric-keys nil)
添加到您的 init 文件中.
You could use M-x customize-variable
RET css-electric-keys
RET to set this list to nil, or add (setq css-electric-keys nil)
to your init file.
有时会使用次要模式来实现电气行为,以便您可以更轻松地打开和关闭它们.那些很可能通过 Mx apropos-command
RET electric
RET 找到,和您可能会使用主模式挂钩来确保禁用电动次要模式,方式与此类似:
Sometimes a minor mode is used to implement electric behaviours, so that you can switch them on and off more easily. Those would likely be found via M-x apropos-command
RET electric
RET, and you would probably use a major mode hook to ensure that the electric minor mode was disabled, in a similar fashion to this:
(add-hook 'MAJORMODE-mode-hook 'my-MAJORMODE-mode-hook)
(defun my-MAJORMODE-mode-hook ()
(ELECTRICMODE-mode 0))
这篇关于在 Emacs 中全局禁用自动缩进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!