tabs - Sublime Text不会在缩进时将制表符转换为空格...为什么以及如何解决它?

标签 tabs indentation sublimetext sublimetext3 spaces

我一直在有效地使用Sublime文本。我有一个困扰我的问题。

当我键入JavaScript代码时,如果将Tab键另外按到提供的缩进级别,则Tab键不会转换为空格。

以下屏幕截图可以帮助您了解我的问题:

如您所见,缩进的初始级别正确设置为8个空格。如果我再按一次制表符,则会插入一个实际的制表符,而不是我想要的4个空格。

以下是我的User 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,

}

该配置似乎已正确设置。是否知道为什么会发生以及如何解决?

最佳答案

有时smart_indent可能使事情变得困惑。尝试将以下行添加到“首选项”>“设置用户”
"smart_indent": false

关于tabs - Sublime Text不会在缩进时将制表符转换为空格...为什么以及如何解决它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22579424/

相关文章:

visual-studio - 如何在 Visual Studio 2015 中很好地禁用文档?

c# - 代码清理 : Best way to split long statement over multiple lines

xml - IXMLDocument.SaveToFile() 使用制表符而不是空格进行缩进

regex - 是否可以使用正则表达式来驼峰化/下划线字符串?

matlab - .m 文件作为 MATLAB/Octave for Sublime Text

jquery - jCarousel + jQuery UI 选项卡问题 : Hidden panel list width is being incorrectly calculated

ios - xcode 6 自定义标签栏在选择图像之前不显示图像

sublimetext3 - 在Sublime Text 3 .tmTheme文件中,设置类型为“不可见”和“阴影”

类似 macOS Swift Safari 的选项卡

f# - #indent "off"在 F#