无论主模式如何,如何强制使用空格代替制表符? [英] How to force spaces instead of tabs regardless of major mode?

查看:77
本文介绍了无论主模式如何,如何强制使用空格代替制表符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望所有制表符都为4个空格。我在 .emacs

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)

但是,这被我可以使用的一些主要模式主题所覆盖。是否可以通过我的 .emacs 文件强行解决此问题?

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

请注意,虽然主要模式不是基于 c-mode 不太关心 c-basic-indent ,并且可能会使用它们自己的,特定于模式的缩进变量。在这种情况下,无法手动配置这些变量。

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天全站免登陆