j6t
j6t

Reputation: 13377

VS Code indent width 4, but still have tab width 8, how?

I have an old code base that uses a weird indentation style. It uses tab width 8, but indents 4 notches, replacing 8 spaces by tabs where possible.

Code should look like this:

____if (foo) {
TAB---->if (bar) {
TAB---->____something();
TAB---->}
____}

I have installed the EditorConfig for Visual Studio Code extension and my .editorconfig has this:

root = true

[*]
insert_final_newline = true
indent_size = 4
tab_width = 8

But the existing code looks like this:

____if (foo) {
TAB>if (bar) {
TAB>____something();
TAB>}
____}

When I add indent_style = tab, the existing code looks correct again, but when I type new code, I get this:

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

How can I achieve the desired display and indentation behavior?

Upvotes: 4

Views: 1876

Answers (1)

jhasse
jhasse

Reputation: 2593

This is a bug / missing feature in VSCode itself: https://github.com/microsoft/vscode/issues/10339

Upvotes: 2

Related Questions