Sublime Forum

Format CSS code - one line per selector

#1

hey guys,

after trying to move away from Dreamweaver for years this time i am very nearly there! I have found solutions or workarounds for most of the things i miss from DW but there is one thats really causing me trouble. I like to have my CSS code for each selector on one line.

for example:

#site-description {float: none; line-height: 1.4em; margin: 0; padding: 0; }

Not the usual:
#site-description {
float: none;
line-height: 1.4em;
margin: 0;
padding: 0;
}

Dreamweaver has a feature (apply source formatting) that lets me toggle between the two really easily - i just cant find a way to replicate it in Sublime.

this website calls it http://www.cssportal.com/format-css/index.php ‘One Line per Style’

I have HTML-CSS-JS Prettify installed but there is not the option to do the above.

does anyone have any thoughts? I dont want to have to take CSS in and out of DW to format it

Thanks for any comments

0 Likes

#2

I guess if your CSS doesn’t contain strings with ;\n inside, just do a find and replace for ;\n\s*(?!\}) and replace with a semicolon followed by a single space

0 Likes