Sublime Text 3: 4个空格的制表符不只适用于javascript文件

Sublime Text 3: 4 spaces for tab not working only for javascript files

本文关键字:适用于 javascript 文件 制表符 Text 4个 空格 Sublime      更新时间:2023-09-26

在Sublime Text 3我有4个tab空格在用户偏好。这是设置文件的一部分:

{
    ...
    // The number of spaces a tab is considered equal to
    "tab_size": 4,
    // Set to true to insert spaces when tab is pressed
    "translate_tabs_to_spaces": false,
    // If translate_tabs_to_spaces is true, use_tab_stops will make tab and
    // backspace insert/delete up to the next tabstop
    "use_tab_stops": true,
    // Set to false to disable detection of tabs vs. spaces on load
    "detect_indentation": 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,
    ...
}

它工作良好,除了Javascript文件,其中制表符空格为2。我不明白为什么。

帮忙吗?

我尝试创建Javascript特定的设置文件,但它也不工作。

我也面临同样的问题。如果你打开一个现有的文件,其中选项卡设置为2个空格(从GitHub加载的文件大多有这个),就会出现问题。另一方面,如果你创建了一个新的.js文件,选项卡会被设置为4。

正如@OdatNurd所提到的,你有"detect_indentation"设置为True。