原子-强制制表符宽度2 [英] Atom - Force Tab Width 2

查看:91
本文介绍了原子-强制制表符宽度2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是从Sublime Text切换到Atom以便完全开源.

I just switched from Sublime Text to Atom in order to turn completely open source.

我遇到了非常简单的问题:我希望Atom始终使用(!),并且在任何情况下都使用制表符宽度2,并用空格替换制表符.此设置在gedit或Sublime Text中非常简单,但是无论我尝试什么:当我启动一个新文件时,选项卡大小为2(好!).当我使用现有文件时,选项卡大小有时为4.我发现这有点烦人.

I have trouble with something very very simple: I want Atom to use always (!) and under any circumstances tab width 2 and replace tab with spaces. This setting is so simple in gedit or Sublime Text, but no matter what I am trying: When I start a new file, tab size is 2 (good!). When I use an existing file, tab size is sometimes 4. I find that a bit annoying.

在屏幕截图中可以看到我在编辑器中的当前设置:

My current setting in Editor are seen in the screenshot:

推荐答案

标签设置不止一个

每个软件包(例如 python语言)都有自己的标签设置.语言是使用全局默认值还是使用自己的默认值,取决于创建包的人,但是您通常可以覆盖它.

There is more than one tab setting

Each package (such as python-language) has its own tab setting(s). Whether the language uses the global default or its own default is up to whoever created the package, but you can generally override it.

在屏幕截图中,您已将标签类型"设置为软".它将使用空格而不是制表符.您保留了默认的标签宽度2.这是您的全局设置.

In your screenshot, you have set the "Tab Type" to "soft". That will take care of using spaces rather than tabs. You have left the default tab width of 2. That is your global setting.

现在,如果您在"Packages"下查找并搜索"python",则会找到一个名为"language-python"的软件包.单击其设置按钮,您将找到许多特定于语法的设置.

Now, if you look under "Packages" and search for "python" you will find a package named "language-python". Click on its settings button and you will find a number of syntax-specific settings.

  • Python语法
  • Python控制台语法
  • Python追溯语法
  • 正则表达式(Python)语法

每个都有其自己的制表符长度设置.您可以在此处将它们显式设置为2,以覆盖程序包的默认值. (您可能主要关心第一个Python语法.)

Each of those grammars has its own Tab Length setting. You can set them explicitly to 2 here to override the package's default. (You probably mostly care about the first one, Python Grammar.)

对于Python,该软件包已显式配置为默认为4个空格,这可能是因为Python对空格非常了解,并且

In the case of Python, the package is explicitly configured to default to 4 spaces, probably because Python is very opinionated about whitespace, and PEP 8 recommends 4-space indents. You can see the default package setting here in the package's source:

https://github.com/atom/language-python/blob/master/settings/language-python.cson

'autoIndentOnPaste': false
'softTabs': true
'tabLength': 4

这将覆盖全局默认值.这就是为什么Python语法不像大多数软件包那样采用全局制表符宽度的原因.

This overrides the global default. That's why Python Grammar does not honor the global tab width, the way that most packages do.

此外,由于语法原因,某些软件包将覆盖您的设置.例如,语言制作将覆盖并使用实际制表符而不是空格,因为这是必需的制造.

Additionally, certain packages will override your settings for syntax reasons. For example, language-make will override and use real tabs instead of spaces, because that is required by make.

对于Python,存在使用空格的替代. language-python设置页面为您提供了一个更改缩进级别的位置,但是它不提供切换到使用制表符的方式. (这可能是合理的,因为Python中的制表符和混合缩进是难以调试的语法错误的常见原因.)

In the case of Python, there is an override to use spaces. The language-python settings page offers a spot for you to change the indentation level, but it does not offer a way to switch to using tab characters. (That's probably justifiable, as tab characters and mixed indentation in Python are a very common cause of difficult-to-debug syntax errors.)

最后,有时直到重新加载Atom窗口后,设置才能完全生效.您可以使用Window: Reload命令来执行此操作.或使用键盘:

Lastly, sometimes settings don't take effect completely until you reload the Atom window. You can use the Window: Reload command to do so. Or using the keyboard:

  • Mac: Ctrl Opt Cmd L
  • Windows/Linux: Ctrl Alt R
  • Mac: CtrlOptCmdL
  • Windows/Linux: CtrlAltR

这篇关于原子-强制制表符宽度2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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