【发布时间】:2014-04-30 00:57:50
【问题描述】:
我一直在非常有效地使用 Sublime 文本。我有一个问题仍然困扰着我。
当我键入 JavaScript 代码时,如果 tab 在提供的缩进级别之外被按下,则制表符不会转换为空格。
下面的截图可以帮助你理解我的问题:
如您所见,缩进的初始级别正确格式化为 8 个空格。如果我再次按 tab,则会插入一个实际的制表符,而不是我想要的 4 个空格。
以下是我的用户Preferences.sublime-settings配置文件:
{
"color_scheme": "Packages/User/Cobalt (SL).tmTheme",
"detect_indentation": false,
"expand_tabs_on_save": true,
"font_size": 10,
"ignored_packages":
[
"Vintage"
],
"tab_size": 4,
"translate_tabs_to_spaces": true,
"trim_automatic_white_space": true,
"use_tab_stops": true,
// Calculates indentation automatically when pressing enter
"auto_indent": true,
// Makes auto indent a little smarter, e.g., by indenting the next line
// after an if statement in C. Requires auto_indent to be enabled.
"smart_indent": true,
// Adds whitespace up to the first open bracket when indenting. Requires
// auto_indent to be enabled.
"indent_to_bracket": false,
// Trims white space added by auto_indent when moving the caret off the
// line.
"trim_automatic_white_space": true,
}
配置似乎设置正确。知道为什么会发生这种情况以及如何解决吗?
【问题讨论】:
-
嗯,作为一个快速的健全性检查,你能告诉我
view.settings().get("translate_tabs_to_spaces")的结果吗?此外,您的首选项中有一个额外的逗号。 ST 处理它,但只是想如果你没有看到它,我会告诉你。 -
@skuroda,感谢您的建议。对不起,我只能在这个星期五回来工作。然后,我会尝试你的建议并回复。
-
view.settings().get("translate_tabs_to_spaces")正在返回False -
这意味着某些东西正在改变该文件中的设置。它可以是插件,也可以是 ST 设置。在我们开始使用插件之前,请尝试在您的用户首选项文件中将
detect_indentation设置为false。 -
嗯,这有点令人失望(因为我希望这将是一个简单的解决方案)。右下角是“空格”还是“制表符”?您是否为 JavaScript 文件创建了任何自定义设置?你能列出你已经安装的插件吗?
标签: tabs indentation sublimetext sublimetext3 spaces