如何强制空格而不是标签,而不管主要模式 [英] How To Force spaces instead of tabs regardless of major mode

查看:165
本文介绍了如何强制空格而不是标签,而不管主要模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让所有的标签都是4个空格。我在.emacs中有以下内容

 (setq-default indent-tabs-mode nil)
(setq c-基本缩进4)
(setq tab-width 4)

但是这被覆盖一些我可以使用的主要模式主题。有没有办法通过我的.emacs文件强制这个问题?

解决方案

尝试覆盖任何主要模式覆盖: / p>

 (add-hook'after-change-major-mode-hook 
'(lambda()
(setq-default indent-tabs-mode nil)
(setq c-basic-indent 4)
(setq tab-width 4)))
注意,不是基于 c-mode 的主要模式不太在乎 c-basic-indent ,可能会使用自己的模式特定的缩进变量。在这种情况下,手动无法配置这些变量。


I want all tabs to be 4 spaces. I have the following in .emacs

(setq-default indent-tabs-mode nil)
(setq c-basic-indent 4)
(setq tab-width 4)

But this gets overwritten by some of the major mode themes that I can use. Is there a way to force this issue through my .emacs file?

解决方案

Try this to overwrite whatever any major mode overwrites:

(add-hook 'after-change-major-mode-hook 
          '(lambda () 
             (setq-default indent-tabs-mode nil)
             (setq c-basic-indent 4)
             (setq tab-width 4)))

Note though that major modes that aren't based on c-mode are not likely to care about c-basic-indent and may potentially use their own, mode-specific indentation variables. In such cases, there's no way around configuring these variables manually.

这篇关于如何强制空格而不是标签,而不管主要模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆