3

How to configure VScode to keep CSS rules with only one property on a single line when autoformatting? Here is the expected result :

.p-auto { padding: auto !important; }
.px-0 {
 padding-left: 0 !important;
 padding-right: 0 !important;
}

I already tryed a lot of things :

Any idea ?

asked Nov 30, 2025 at 11:05

2 Answers 2

1
+50

In VS Code/Prettier, you just can’t do that
The1 prop on 1 line / multi-prop on multi-linething isn’t supported anywhere.
No hidden flag, no ext, nothing...

Prettier is like "my way or no way", so you’re stuck with:

  1. put the file in .prettierignore only for the css you wanna keep "your style" on:
/src/styles/special.css
  1. prettier-ignore */` but yeah... have to repeat it, super annoying.

  2. another formatter but honestly none of them handle that exact rule cleanly, and prettier team already said "nope".

so ...not doable right now, unless you just skip formatting on those files.

kinda sucks but that’s the current state.

answered Dec 4, 2025 at 10:32
Sign up to request clarification or add additional context in comments.

Comments

0

Some times simply disable CSS formatting entirely:

"[css]": {
 "editor.formatOnSave": false
}

Then format only HTML/JS/TS/Svelte/etc.

answered Nov 30, 2025 at 11:10

1 Comment

Thanks, but I already disabled this option and I want to disable formatting only for some files, not all CSS files. Furthermore, this is not exactly what I asked. Ideally, I would like to format single properties rules on one line while keeping default formatting for multi-property rules

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.