【问题标题】:Configure vscode json formatting spaces配置 vscode json 格式化空间
【发布时间】:2017-06-26 11:52:13
【问题描述】:

我想将 vscode 配置为使用 2 个缩进空格来格式化我的 JSON 对象,而不是默认情况下的 4 个空格。我该怎么做?

【问题讨论】:

标签: json visual-studio-code code-formatting


【解决方案1】:

将这一行粘贴到 VSCode 的 settings.json 中,一切就绪:

"[json]": {
  "editor.insertSpaces": true,
  "editor.tabSize": 2
}

【讨论】:

  • @JonathanPool 我不知道为什么。我适用于 .vscode/settings.json 和全局 settings.json ~/.config/Code/User/settings.json 中的项目 settings.json
【解决方案2】:

安装编辑器配置插件。

ext install EditorConfig

使用以下内容将.editorconfig 文件添加到您的项目根目录:

[*.json]
indent_style = space
indent_size = 2

另见:

https://github.com/editorconfig/editorconfig-vscode

http://editorconfig.org/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-16
    • 2020-12-12
    相关资源
    最近更新 更多