简体   繁体   English

如何在更漂亮的 vs 代码中设置逗号

[英]how to set commas in prettier vs code

I have css file.我有 css 文件。 I want to set prettier vs code so that after writing a comma, the selector I wrote remained in line with the previous selector.我想设置更漂亮的 vs 代码,这样在写了一个逗号之后,我写的选择器仍然和之前的选择器保持一致。 But when i save the file, the selector will be entered to next line但是当我保存文件时,选择器将输入到下一行

I want to save the code like this (my expectation)我想保存这样的代码(我的期望)

在此处输入图像描述

But prettier set the code like this (h3 entered to next line)但是更漂亮地设置这样的代码(h3输入到下一行) 在此处输入图像描述

How to fix this problem?如何解决这个问题? I set trailling comma to none but it doesn't work.我将尾随逗号设置为无,但它不起作用。 在此处输入图像描述

I think that config you changed only applies to JavaScript files (notice the reference to ES5).我认为您更改的配置仅适用于 JavaScript 文件(注意对 ES5 的引用)。

As far as CSS, prettier is opinionated and they decided that each selector should have its own line ( this PR implements that behaviour ).至于 CSS,prettier 是固执己见的,他们决定每个选择器都应该有自己的行(这个 PR 实现了这种行为)。 I don't think there's a config to change that behaviour.我认为没有配置可以改变这种行为。

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

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