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

谢谢!


当前回答

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

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

其他回答

如果你从谷歌来到这里,因为tab不缩进,这也可能是因为“tab移动焦点”是打开的。它在右下角,如果你有一个足够大的显示器,你可能会错过它,尽管它是突出显示的。

点击绿色区域或Ctrl + M使它停止。我不确定它是否可以完全禁用,我也不知道为什么代码编辑器会想要搞砸缩进之类的东西。

如果你用的是C/ c++:

>首选项>设置或[Ctrl+Shift+P] 搜索“设置用户界面” 搜索“c_cpp格式化” 将格式引擎从"clangFormat"改为"vcFormat"

然后在“c_cpp>vc format”下更改的所有内容将被激活。

截图

VSCode插件Vetur;用于VueJS应用程序正在覆盖我的设置。

将vetr .format.options. tabsize设置为我喜欢的空格数就可以工作了。

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

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

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

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

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