VS Code 缩进宽度为 4,但制表符宽度仍然为 8,怎么办?

j6t*_*j6t 5 visual-studio-code editorconfig

我有一个旧的代码库,它使用奇怪的缩进样式。它使用制表符宽度 8,但缩进 4 个槽口,尽可能用制表符替换 8 个空格。

代码应如下所示:

____if (foo) {
TAB---->if (bar) {
TAB---->____something();
TAB---->}
____}
Run Code Online (Sandbox Code Playgroud)

我已经安装了EditorConfig for Visual Studio Code扩展,并且我的.editorconfig有:

root = true

[*]
insert_final_newline = true
indent_size = 4
tab_width = 8
Run Code Online (Sandbox Code Playgroud)

但现有的代码如下所示:

____if (foo) {
TAB>if (bar) {
TAB>____something();
TAB>}
____}
Run Code Online (Sandbox Code Playgroud)

当我添加 时indent_style = tab,现有代码看起来再次正确,但是当我键入新代码时,我得到以下结果:

____if (foo) {   // after hitting Enter on this line the next line is indented too far:
TAB---->____something
____}
Run Code Online (Sandbox Code Playgroud)

如何实现所需的显示和缩进行为?

jha*_*sse 2

这是 VSCode 本身的错误/缺失功能:https ://github.com/microsoft/vscode/issues/10339