[英]VS Code - Prevent Format Document from putting CSS on one line
I use format document a ton in VSCode and was wondering if there was a way to prevent VSCode from concatenating my CSS classes into one line and leave them as is? 我在VSCode中大量使用了格式文档,并且想知道是否有一种方法可以防止VSCode将我的CSS类连接成一行并保持原样?
For example, I'd have some CSS like below 例如,我将有如下所示的CSS
.a,
.b {
font-size: 10px;
}
Then when formatting the document is complete, it'll look like this: 然后,当格式化文档完成时,它将如下所示:
.a, .b {
font-size: 10px;
}
Is this something that can be prevented with VSCode or is there a plugin that I can install to do the same thing? 这是可以用VSCode阻止的事情吗,或者我可以安装一个插件来做同样的事情吗?
You have a few options. 您有几种选择。
1) You can use the js-beautify plugin (or similar) - https://marketplace.visualstudio.com/items?itemName=HookyQR.beautify . 1)您可以使用js-beautify插件(或类似插件)-https://marketplace.visualstudio.com/items?itemName =HookyQR.beautify 。 Once installed you can use the 'preserve_newlines' setting in the .jsbeautifyrc config file
安装后,您可以使用.jsbeautifyrc配置文件中的'preserve_newlines'设置
2) This can be done in vscode settings under the option 'html.format.preserveNewLines' 2)这可以在vscode设置中的“ html.format.preserveNewLines”选项下完成
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.