You can do this using the scripting language of your favorite editor.
For example, in SciTE:
function ExpandContractCSS() local ext = string.lower(props["FileExt"]) if ext ~= "css" then return end local line = GetCurrentLine() local newForm if string.find(line, "}") then -- On one line newForm = string.gsub(line, "; *", ";\r\n ") newForm = string.gsub(newForm, "{ *", "{\r\n ") newForm = string.gsub(newForm, " *}", "}") else -- To contract -- Well, just use Ctrl+Z! -- Maybe not, code to come if interest end if newForm ~= nil then ReplaceCurrentLine(newForm) end end
GetCurrentLine and ReplaceCurrentLine are just convenient features from my collection, I can give them (and do some compression) if you are interested.
source share