Vscode: [css] provide css formatter

Created on 24 Jan 2017  路  17Comments  路  Source: microsoft/vscode

Refs #19047

Our css does not support formating a range, thus formatOnPaste is useless for CSS.
And this is actually the only use case I personally have for formatOnPaste, since I always copy rules from chrome dev tools and they are always wrongly indented. However formatOnPaste does not help me here

*out-of-scope css-less-scss feature-request

Most helpful comment

BTW there's only so much the VSCode team can work on and maintain. We prioritize on the number of votes on the issues (馃憤 on the issue description). That's also why we keep these bugs open.

Besides, not everything should and can be bundled with VSCode. That's why we have an extension API and a marketplace. That lets us share the maintenance work, encourage participation & innovation and want to keep the VSCode download small.

Please support these extension authors by using their extensions and give feedback. File issues describing the functionality they are missing (e.g. don't remove my empty lines).

Adding 'format on save' requires implementing a OnTypeFormattingEditProvider

All 17 comments

Life is unfair. There is also formatOnType for json and no party without hangover

There are extensions that provide formatting css. I'd suggest you try one of these.
IMO we should not package it all to VSCode. We want to share the maintenance work and want to keep the VSCode download small.

Sure but then we should somehow communicate this to our users of formatOnPaste setting

@isidorn Can you create a separate issue for the suggestion to communicate it better (or rename this issue)

@aeschli part of that is already captured in https://github.com/Microsoft/vscode/issues/19160

Apart from that I would expect that our docs cover this - created this one https://github.com/Microsoft/vscode-docs/issues/809

CSS formatting is an integral part of a text editor. I request you @jrieken that you'll look into this.

@vkWeb CSS formatting is available as an extension. Check out the markerplace

@aeschli Ya I know that :). I was trying to say that a code editor must have some kind of default formatting options for CSS. VSCode lacks that. Though, It's not a big deal ;)

need css formatter:pray:

@levinit You can use Prettier - A great code formatter for JS, CSS & Typescript.

@vkWeb thx ,I have installed it, it works.(although I hope vscode integrates css formatter:yum:)

@levinit Once you get into general purpose programming or back-end stuff. You'll realize VSCode is a gem. A true gem! 鉂わ笍 馃槂

Is there actually a css formatter in the marketplace that obeys the editorconfig indentation settings? Because I've tried about half a dozen and haven't found one that does yet.

The extensions that "handle formatting css" do not work while you type, and even then none of them follow the rules set in your prettier, scss-lint, editorconfig, etc.

Your Javascript editor formats/indents as you type, no extensions required. Your CSS editor should do the same. There's no excuse for it not to.

To drive the point home, here is VSCode on the left and WebStorm on the right. Which editor would you rather use? Imagine if this file was more complicated.

code-vs-webstorm

Your editor does the kind of behavior demonstrated on the right with Javascript. Why on earth doesn't it do the same _basic_ formatting for css/scss?

Unfortunately, prettier is not working for scss/css files in VS Code, as you can see. I have prettier installed along with Beautify css/sass/scss - none of them do anything, as the gif demonstrates.

If I use the Format Code key command it formats css in a way that breaks all the scss-lint rules I have (for one, it removes all empty lines from the entire file).

Fact of the matter is, WebStorm is eating your lunch on a feature that should be native to VSCode which is _basic_ formatting of css as shown in the above gif. Don't pass the buck just because CSS-in-JS is so popular.

And yes, the lack of this feature is more than enough to keep people from "making the switch" to VS Code regardless of the other things it has. WebStorm is a superior CSS editor out of the box. PERIOD. And you are settling for that? Really? Where's your developer pride? This ticket is over 1.5 years old for crying out loud, and it's been closed a bunch of times by people who apparently have ZERO pride in writing an acceptable css editor. You're alienating a ton of people.

BTW there's only so much the VSCode team can work on and maintain. We prioritize on the number of votes on the issues (馃憤 on the issue description). That's also why we keep these bugs open.

Besides, not everything should and can be bundled with VSCode. That's why we have an extension API and a marketplace. That lets us share the maintenance work, encourage participation & innovation and want to keep the VSCode download small.

Please support these extension authors by using their extensions and give feedback. File issues describing the functionality they are missing (e.g. don't remove my empty lines).

Adding 'format on save' requires implementing a OnTypeFormattingEditProvider

Besides, not everything should and can be bundled with VSCode. That's why we have an extension API and a marketplace. That lets us share the maintenance work, encourage participation & innovation and want to keep the VSCode download small.

Please support these extension authors by using their extensions and give feedback. File issues describing the functionality they are missing (e.g. don't remove my empty lines).

I understand that it's not possible to bundle everything in one BUT if you have built-in HTML and JS formatter and you don't have CSS formatter, something is really illogical here.
JS, HTML, CSS - it's all very closely related.

You say - use add-ons from Marketplace.
I'd really like to do that, but please see how some add-ons work.
Many of them do not have proper documentation and many bugs. Many things don't work properly.
Add-ons developers leave their projects. I often see an decription like: _"I don't have time to work on it, if you want you can take over this project"_
Maybe I'm too pessimistic but thats how it works, unfortunately...

To sum up - the built-in CSS formatter is something really important. I hope you add it

Closing as we still have no plans to include a CSS formatter as discussed in https://github.com/microsoft/vscode/issues/19166#issuecomment-409928738

Was this page helpful?
0 / 5 - 0 ratings

Related issues

curtw picture curtw  路  3Comments

borekb picture borekb  路  3Comments

ryan-wong picture ryan-wong  路  3Comments

philipgiuliani picture philipgiuliani  路  3Comments

lukehoban picture lukehoban  路  3Comments