Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css] provide css formatter #19166

Closed
isidorn opened this issue Jan 24, 2017 · 18 comments
Closed

[css] provide css formatter #19166

isidorn opened this issue Jan 24, 2017 · 18 comments
Assignees
Labels
css-less-scss Issues and items concerning CSS,Less,SCSS styling feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan
Milestone

Comments

@isidorn
Copy link
Contributor

isidorn commented Jan 24, 2017

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

@isidorn isidorn added the feature-request Request for new features or functionality label Jan 24, 2017
@jrieken jrieken assigned aeschli and unassigned rebornix and jrieken Jan 24, 2017
@jrieken
Copy link
Member

jrieken commented Jan 24, 2017

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

@aeschli
Copy link
Contributor

aeschli commented Jan 24, 2017

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.

@isidorn
Copy link
Contributor Author

isidorn commented Jan 24, 2017

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

@aeschli
Copy link
Contributor

aeschli commented Jan 24, 2017

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

@isidorn
Copy link
Contributor Author

isidorn commented Jan 24, 2017

@aeschli part of that is already captured in #19160

Apart from that I would expect that our docs cover this - created this one microsoft/vscode-docs#809

@vkWeb
Copy link

vkWeb commented Sep 18, 2017

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

@aeschli
Copy link
Contributor

aeschli commented Sep 19, 2017

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

@vkWeb
Copy link

vkWeb commented Sep 19, 2017

@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 ;)

@levinit
Copy link

levinit commented Oct 15, 2017

need css formatter:pray:

@vkWeb
Copy link

vkWeb commented Oct 15, 2017

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

@levinit
Copy link

levinit commented Oct 17, 2017

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

@vkWeb
Copy link

vkWeb commented Oct 17, 2017

@levinit Once you get into general purpose programming or back-end stuff. You'll realize VSCode is a gem. A true gem! ❤️ 😃

@Neutrino-Sunset
Copy link

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.

@stevensacks
Copy link

stevensacks commented Aug 2, 2018

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.

@aeschli
Copy link
Contributor

aeschli commented Aug 2, 2018

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

@kanlukasz
Copy link

kanlukasz commented Aug 6, 2019

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

@aeschli
Copy link
Contributor

aeschli commented Oct 9, 2019

Closing as we still have no plans to include a CSS formatter as discussed in #19166 (comment)

@aeschli aeschli closed this as completed Oct 9, 2019
@aeschli aeschli added the *out-of-scope Posted issue is not in scope of VS Code label Oct 9, 2019
@aeschli aeschli reopened this Mar 11, 2022
@aeschli aeschli modified the milestones: Backlog, March 2022 Mar 11, 2022
@aeschli aeschli removed the *out-of-scope Posted issue is not in scope of VS Code label Mar 11, 2022
@aeschli aeschli mentioned this issue Mar 21, 2022
3 tasks
@ArturoDent
Copy link

Nit: In the description for CSS > Format: Newline Between Selectors, it says

Separate selectors with a new line.

I believe that should say newline rather than new line.

@isidorn

@github-actions github-actions bot locked and limited conversation to collaborators May 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
css-less-scss Issues and items concerning CSS,Less,SCSS styling feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan
Projects
None yet
Development

No branches or pull requests

11 participants