Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio 2017 disable css formatting unnecessary spaces

I have a problem when I trying to format css code. Visual studio gives me unnecessary spaces in css

Before format css code in visual studio :

.test-parent {
}

.test-parent .test-child {
}

.test-parent .test-child .test-child-child {
}

After format css code in visual studio :

.test-parent {
}

    .test-parent .test-child {
    }

        .test-parent .test-child .test-child-child {
        }

Is it possible to disable unnecessary spaces in visual studio 2017 ?

like image 734
Iris Avatar asked Nov 03 '17 11:11

Iris


People also ask

How do I beautify CSS in Visual Studio?

press F1 or ctrl+shift+p and then enter beautify .. alt+shift+f did nothing, but typing beautify...

How do I tidy up code in Visual Studio?

You can also run code cleanup across your entire project or solution. Right-click on the project or solution name in Solution Explorer, select Analyze and Code Cleanup, and then select Run Code Cleanup.


1 Answers

I believe this feature is called "Hierarchical Indentation".

You should be able to disable it by completing the following.

  • Click the Tools menu
  • Click Options...
  • Scroll down and expand Text Editor
  • Scroll down and expand CSS
  • Select Advanced
  • Set Hierarchical indentation to "Off".

This should stop Visual Studio formatting your CSS in the nested format.

like image 155
James Avatar answered Oct 28 '22 22:10

James