How can i format visual studio code to add an indented space between curly brackets in CSS when i hit enter?

Viewed 46

When I open the curly brackets in CSS and hit enter, it just jumps to the next line like this:

body {
}

It doesn't add a new line with an indentation like it used to, I tried looking through the setting and trying everything but couldn't get a result. I want it to look like this when I press Enter:

body {
    
}
3 Answers

You can try the following:

  1. Check if you have set your default formatter to prettier
  2. You can check the box to Format On Save or ;
  3. Autosave: There are are currently 4 options available -:

a) off

b) afterDelay

c) onFocusChange

d) onWindowChange

To anyone who is facing this problem in VSCode. This feature is not related to any extension, not Prettier or any other extension. What you have to do to fix this bug is:

  1. Go to the settings
  2. Search for Folding Strategy and choose the Auto option
  3. Then enable Folding

It adds that indentation in both HTML and CSS

enter image description here

Related