Blog of Petar Vucetin, containing my thoughts, comments and questions. RSS Feed TwitterDiigoFacebookFriendfeed


Tip: Cleaning up CSS files in Visual Studio

Recently i have been working a lot with CSS. One thing I noticed is that I had to do a lot of experimenting to get things working which left the CSS properties in somewhat of a disarray. Working with my friend Adrian, who frightens me a little bit with his pedantic code manners, I wanted to do something about the CSS files. Here is my recipe.

Go get the CSSTidy. Put it somewhere you can find it. I keep all my tools under D:\Program Files\Tools and expose those on my explorer bar.

image

In Visual Studio, add new External tool:

image

Click add to add new external tool in the dialog:

image

Title: CssTidy

Command: [where ever you installed it]\CssTidy.exe

Arguments: $(ItemPath)  --template=low --sort_properties=true  --timestamp=true $(ItemFileName).css

Initial Directory: $(ItemDir)

You will notice that i had to use fixed extension in the arguments. For some reason this command line did not work:

$(ItemPath)  --template=low --sort_properties=true  --timestamp=true $(ItemFileName)$(ItemExt)

You can find CSSTidy arguments here. Beware, this tool might change your CSS in way that your layout does not work anymore. I am using the minimum options which is just the property sort.

Enjoy.

 
Posted by Petar Vucetin

blog comments powered by Disqus