在Visual Studio Code中使用Format Code命令时,它不尊重我的缩进设置(“editor. exe”)。tabSize": 2).它使用的是4的标签大小。知道为什么会这样吗?

谢谢!


当前回答

Visual Studio Code检测每个默认值的当前缩进并使用它——忽略.editorconfig

同时将"editor.detectIndentation"设置为false

(文件->首选项->设置)

其他回答

Visual Studio Code检测每个默认值的当前缩进并使用它——忽略.editorconfig

同时将"editor.detectIndentation"设置为false

(文件->首选项->设置)

禁用所有插件(然后逐个启用并验证)

我有一个“。editorconfig”文件在父目录(ionic项目)的值“indent_size = 2”,它确实覆盖了我为我的工作空间选择的任何值! 我一改,问题就解决了。

很可能你已经安装了一些格式化扩展,例如JS-CSS-HTML Formatter。

如果是这样,那么只需打开命令面板,键入“Formatter”并选择Formatter Config。然后编辑“indent_size”的值。

附注:编辑后不要忘记重新启动Visual Studio Code:)

下面的设置解决了我的问题

  "editor.detectIndentation": false,
  "editor.insertSpaces": false,
  "editor.tabSize": 2,