Js-beautify: Add option to keep single-line rules in CSS

Created on 3 Dec 2017  ·  4Comments  ·  Source: beautify-web/js-beautify

Description

Greetings!

if I have this
footer { padding: 1%; }

then after Shift+Alt+F I get

    footer {
        padding: 1%;
    }

Is there an option to kee 'one-line-rule' as it is?

Tried

"beautify.options": {"brace_style": "collapse,preserve-inline"}

but no luck

Settings

 {
    "window.zoomLevel": -1,
    "workbench.sideBar.location": "right",
    "files.autoSave": "afterDelay",
    "files.autoSaveDelay": 1000,
    "editor.cursorStyle": "underline",
    "liveServer.settings.donotShowInfoMsg": true,
    "liveServer.settings.donotVerifyTags": false,
    "html.format.contentUnformatted": "pre,code,textarea,li",  
}
css blocked enhancement

Most helpful comment

Maybe it should be an option like max_preserve_single_line_properties configured with the maximum number of properties to keep in a single line.

Formatted:

.fill {
    flex: 1 1 auto;
}

.item-name input {
    font-size: 1.5em;
}

.avatar {
    border-radius: 50%;
    margin-right: 10px
}

.avatar-32 {
    width: 32px;
    height: 32px
}

.avatar-64 {
    width: 64px;
    height: 64px
}

.avatar-100 {
    width: 100px;
    height: 100px
}

.avatar-128 {
    width: 128px;
    height: 128px
}

.details {
    padding: 2em;
}

.form-actions {
    direction: rtl;
}

Desired result:

.fill { flex: 1 1 auto; }
.item-name input { font-size: 1.5em; }

.avatar { border-radius: 50%; margin-right: 10px }
.avatar-32 { width: 32px; height: 32px }
.avatar-64 { width: 64px; height: 64px }
.avatar-100 { width: 100px; height: 100px }
.avatar-128 { width: 128px; height: 128px }

.details { padding: 2em; }
.form-actions { direction: rtl; }

All 4 comments

This is related to #1124, but separate since it is asking only to preserve one-line rules.
Neither are present at this time.

Thank You for response @bitwiseman ! :)

Maybe it should be an option like max_preserve_single_line_properties configured with the maximum number of properties to keep in a single line.

Formatted:

.fill {
    flex: 1 1 auto;
}

.item-name input {
    font-size: 1.5em;
}

.avatar {
    border-radius: 50%;
    margin-right: 10px
}

.avatar-32 {
    width: 32px;
    height: 32px
}

.avatar-64 {
    width: 64px;
    height: 64px
}

.avatar-100 {
    width: 100px;
    height: 100px
}

.avatar-128 {
    width: 128px;
    height: 128px
}

.details {
    padding: 2em;
}

.form-actions {
    direction: rtl;
}

Desired result:

.fill { flex: 1 1 auto; }
.item-name input { font-size: 1.5em; }

.avatar { border-radius: 50%; margin-right: 10px }
.avatar-32 { width: 32px; height: 32px }
.avatar-64 { width: 64px; height: 64px }
.avatar-100 { width: 100px; height: 100px }
.avatar-128 { width: 128px; height: 128px }

.details { padding: 2em; }
.form-actions { direction: rtl; }

This will require at least css tokenization to get it to work (#545). Once we have that this will be implemented the same way it is in the javascript side.

Was this page helpful?
0 / 5 - 0 ratings