【问题标题】:How to make prettier the default formatter in vs code?如何使 prettier 成为 vs 代码中的默认格式化程序?
【发布时间】:2021-01-05 07:46:26
【问题描述】:

我在 vs code 中安装了 prettier 扩展,当我点击格式化文件时,vs code 询问我:“你想使用默认格式化程序格式化还是使用 prettier 格式化程序?”。但我不小心选择了默认格式化程序。如何将其更改为默认设置更漂亮的格式?

【问题讨论】:

标签: visual-studio-code vscode-settings prettier


【解决方案1】:

不知道为什么,但将默认格式化程序设置为 ebsenp.prettier 对我不起作用。但是我发现了一个类似的命令。

  1. ctrl + shift + p
  2. 格式化文档
  3. 配置默认格式化程序
  4. 选择更漂亮

【讨论】:

    【解决方案2】:
    1. 通过单击 vs 代码侧栏左下角的齿轮并从菜单中选择设置,或按 Ctrl+,打开设置,

    2. 在设置窗格的右上角,点击打开文件图标(如果您将鼠标悬停,工具提示将显示“打开设置(JSON)”

    3. 将以下行添加到设置 json:

      "editor.defaultFormatter": "esbenp.prettier-vscode"

    【讨论】:

      【解决方案3】:

      在命令面板(ctrl + shift + p)中,搜索格式,然后选择格式化文档。然后选择 Prettier - Code Formatter。

      注意:如果您没有看到选择默认格式的提示,您可以在“设置”中手动更改此设置。将编辑器:默认格式化程序设置为 ebsenp。

      这里是完整的解决方案: https://www.digitalocean.com/community/tutorials/how-to-format-code-with-prettier-in-visual-studio-code#:~:text=In%20the%20command%20palette%2C%20search,and%20then%20choose%20Format%20Document.&text=Then%20choose%20Prettier%20%2D%20Code%20Formatter,Editor%3A%20Default%20Formatter%20to%20ebsenp.

      【讨论】:

        猜你喜欢
        • 2019-03-06
        • 1970-01-01
        • 2021-10-21
        • 2020-06-25
        • 2021-07-10
        • 2019-03-15
        • 2021-04-24
        • 2023-02-02
        • 2019-08-15
        相关资源
        最近更新 更多