强制 VSCode 始终使用制表符作为缩进

gro*_*190 9 formatter visual-studio-code

当我在 VSCode 中保存文件时,它们会自动格式化。制表符被转换为四个空格。但我更喜欢标签。如何强制 VSCode 使用制表符而不是四个空格?

这些是我的设置。

{
    "files.insertFinalNewline": true,
    "terminal.integrated.shellArgs.windows": [
        "-ExecutionPolicy",
        "Bypass"
    ],
    "files.trimFinalNewlines": false,
    "window.zoomLevel": 0,
    "explorer.confirmDelete": false,
    "workbench.startupEditor": "newUntitledFile",
    "typescript.updateImportsOnFileMove.enabled": "always",
    "typescript.format.semicolons": "remove",
    "editor.formatOnSave": true,
    "editor.detectIndentation": false,
    "editor.tabSize": 4,
    "editor.insertSpaces": false
}
Run Code Online (Sandbox Code Playgroud)

我缺少什么设置来强制 VSCode不用 4 个空格替换制表符

Ric*_*ard 6

在设置编辑器中,搜索“缩进”以找到“编辑器:插入空格”。

(这也可以在语言基础上被覆盖。)

  • 谢谢!但我的 settings.json 已经有 `"editor.insertSpaces": false` 行。我认为这应该禁用制表符到空格的替换。由于某种原因,它不适用于我的 Python 文件...... (3认同)
  • `"editor.detectIndentation": false` - 空格/制表符检测已关闭 (2认同)