简体   繁体   English

VS代码-如何自动格式化CSS?

[英]VS code - How to auto format CSS?

I'm new to VS code and have been searching for a way to auto format CSS when saving data. 我是VS代码的新手,并且一直在寻找一种在保存数据时自动格式化CSS的方法。 Surprisingly, I can't seem to find any good extension or well-explained site of how to auto format CSS in VS code. 令人惊讶的是,我似乎找不到如何在VS代码中自动格式化CSS的任何很好的扩展或解释清楚的网站。

HTML is formatted the moment I saved a file, and want to do the same thing on CSS. 保存文件并希望在CSS上执行相同操作时,HTML就会格式化。

Ideally I want the one like "Beautify" that can be used in Atom. 理想情况下,我希望可以在Atom中使用“美化”之类的东西。

Any advice? 有什么建议吗?

Quite sure you can do this with prettier code formatter plugin . 非常确定您可以使用更漂亮的代码格式化插件来完成此操作。 And you can set format on save true for all languages by adding the following to your user settings json file(dont forget to reload vscode after updating) : 然后,您可以通过将以下内容添加到用户设置json文件中,将所有语言的save设置为true格式(更新后请不要忘记重新加载vscode):

"editor.formatOnSave": true,   

you can enable format on save for a specific language by adding the following too : 您也可以通过添加以下内容来启用特定语言的保存格式:

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

You can use a extension named "Prettier - Code formatter" . 您可以使用名为“ Prettier-Code formatter”的扩展名。 Its great. 这很棒。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM