34

In Visual Studio 2013 when I format my CSS code (Ctrl+K+F) it will sometimes indent my CSS properties into a hierarchy.

For example:

.a { color:red; }
.a .b {color:blue; }

Becomes:

.a {
  color:red;
}

   .a .b {
     color:blue;
   }

When I would prefer:

.a {
  color:red;
}

.a .b {
  color:blue;
}

Is there a way of modifying Visual Studio to prevent this indentation?

0

1 Answer 1

63

Yes, you can set a preference for this from the Tools, Options menu.

Drill down in Text Editor to CSS, and under Advanced, turn Hierarchical Indentation off:

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

This change takes immediate effect, but if your css file is open with a split screen when you make the change it will only take effect in the top panel. Just un-split or close and reopen to remedy. (VS2017)
Isn't this a bug in the text editor? It also happens when styles are not hierarchic, just completely different ones next to another styles.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.