【问题标题】:editorconfig for Visual studio codeVisual Studio 代码的 editorconfig
【发布时间】:2018-05-01 14:59:10
【问题描述】:

我的项目有 .editorconfig 文件:

[*.{js}]
charset = utf-8
indent_style = space
indent_size = 4

我认为这会强制我的 VS Code 使用带有 4 个空格的缩进样式空间。

我从扩展列表中安装了EditorConfig for vs code 扩展。

但仍然没有,我新创建的文件没有自动设置配置的空间样式。有什么问题?

【问题讨论】:

标签: visual-studio-code editorconfig


【解决方案1】:

试试

root = true
[*.js]
indent_style = space
indent_size = 4
charset = utf-8

【讨论】:

    【解决方案2】:

    你也可以试试这个,喜欢的可以换成空格:)

    root = true
    
    [*]
    end_of_line = lf
    charset = utf-8
    trim_trailing_whitespace = true
    insert_final_newline = true
    indent_style = tab
    indent_size = 2
    
    [*.{js,txt,md,css,html,php,py,json,yml,sass,pug}]
    indent_style = tab
    indent_size = 2
    
    [*.{diff,md}]
    trim_trailing_whitespace = false
    

    【讨论】:

      【解决方案3】:

      VS Code需要插件才能使用editorconfig,所以需要安装插件

      【讨论】:

      • 我在问题中说过“我从扩展列表中为 vs 代码扩展安装了 EditorConfig。”
      【解决方案4】:

      我想我找到了解决方案。当我在 VSCode 中右键单击文件夹结构侧边栏创建 .editorconfig 并选择 Generate .editorconfig (从而让插件创建它)它可以工作。

      点击文件下方的空白区域:

      【讨论】:

      • @doublnt 你有安装 VSCode 扩展的 EditorConfig 吗?
      • 当然,我已经安装了扩展和 npm 包。
      • @doublnt 你必须点击上图中的空白处
      • 这个解决方案对我有用。我将现有的.editorconfig 内容复制到剪贴板,删除文件,右键单击并选择Generate .editorconfig,然后将内容粘贴回这个新文件。然后插件开始正常工作。
      • 记得关闭文件再打开。设置将起作用
      猜你喜欢
      • 2020-07-10
      • 2018-12-23
      • 2023-01-02
      • 2021-03-17
      • 2017-08-01
      • 2020-08-09
      • 2022-12-04
      • 2017-02-19
      • 2017-11-25
      相关资源
      最近更新 更多