簡體   English   中英

VS Code 中的 CSS 設置更漂亮

[英]Prettier with CSS settings in VS Code

我在 VS Code 編輯器中添加了 Prettier 擴展。

使用 Less 或 Sass 時,默認設置格式代碼如下:

// Default

.parent_selector {
  .child_selector {
    color: red;
  }
}
// Desired Format

.parent_selector {

  .child_selector {
    color: red;
  }
}

我如何調整 Prettier CSS 設置來實現這一點? 我知道這看起來微不足道,但在更大的代碼庫中,它有助於提高可讀性。

作為替代方法; 可以通過使用stylelint插件和stylelint-config-standard規則來實現。

npm install --save-dev stylelint stylelint-config-standard

安裝它們后,在 VS Code 上繼續ctrl+shift+p並運行命令: stylelint: fix all auto-fixable problems

stylelint:修復所有可自動修復的問題

PS:考慮為stylelint: fix all auto-fixable problems分配鍵盤快捷鍵stylelint: fix all auto-fixable problems命令,以便於訪問。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM