Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually indent needed again when HTML tag is closed in VS Code

In Microsoft VS Code when I'm closing HTML tag (e.g. on bottom image), current position will be moved to the first column and remove tabs indent. Then I need to indent manually with tabs again. How can I fix it?

GIF Example - please click here…

My settings.json file:

...
"editor.detectIndentation": false,
"editor.wrappingIndent": "none",
"editor.trimAutoWhitespace": false,
"files.trimTrailingWhitespace": false,
"files.insertFinalNewline": true,
"html.format.endWithNewline": false,
...
like image 697
Jan Elznic Avatar asked Sep 02 '25 16:09

Jan Elznic


2 Answers

I set the options in settings.json to:


    "editor.detectIndentation": true,
    "editor.autoIndent": false

And it's working now. Fixed.

like image 77
Jan Elznic Avatar answered Sep 04 '25 07:09

Jan Elznic


In your settings.json, "editor.detectIndentation": false, is your issue. Make that true.

i.e.

...
"editor.detectIndentation": true,
"editor.wrappingIndent": "none",
"editor.trimAutoWhitespace": false,
"files.trimTrailingWhitespace": false,
"files.insertFinalNewline": true,
"html.format.endWithNewline": false,
...
like image 24
ifconfig Avatar answered Sep 04 '25 08:09

ifconfig