【问题标题】:Setting tab size/ space size as default in VSCode在 VSCode 中将选项卡大小/空间大小设置为默认值
【发布时间】:2017-08-03 06:06:58
【问题描述】:

我目前正在使用 VSCode,我遇到了这个问题。我想将空间大小设置为 1,标签大小等于 2,作为每个项目的默认值。但它仍然设置为空格:每个项目 4 个。 当我设置空格= 2,并运行美化文件。空间 = 2 时一切看起来都很好。然后我点击保存,将我的文件格式化为缩进大小 4。如何将其设置为默认等于 2 人?

即使我更改了用户设置

【问题讨论】:

  • 您有将制表符转换为空格的选项吗?

标签: html css visual-studio-code vscode-settings


【解决方案1】:

默认情况下,VSCode 会尝试检测文件的缩进选项。所以将 editor.detectIndentation 设置为 false

// When opening a file, `editor.tabSize` and `editor.insertSpaces` will be detected based on the file contents.
  "editor.detectIndentation": false,

【讨论】:

    【解决方案2】:

    EditorConfig 是建立项目范围格式选项的便捷标准:http://editorconfig.org

    有一个支持它的 VSCode 扩展:https://github.com/editorconfig/editorconfig-vscode

    这并不能直接回答您的问题,但效果很好。而且,如果您切换编辑器,您仍然可以通过获取每个编辑器的 EditorConfig 插件来保持您的格式标准。

    【讨论】:

    • 我们如何在 VSCode 中配置 EditorConfig 设置?
    • 只需安装扩展并创建其配置文件,如下所述:editorconfig.org
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-14
    • 2019-08-10
    • 2019-08-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多