Már*_*lim 10 visual-studio-code vscode-settings prettier
我在 vs code 中安装了 prettier 扩展,当我点击格式化文件时,vs code 问我:“你想使用默认格式化程序还是使用更漂亮的格式化程序进行格式化?”。但是我不小心选择了默认的格式化程序。如何将其更改为默认设置更漂亮的格式?
小智 84
单击 VS Code 侧栏左下角的齿轮并从菜单中选择设置,或者按 Ctrl+ 打开设置,
在设置窗格的右上角,点击打开文件图标(如果将鼠标悬停,工具提示将显示“打开设置 (JSON)”
将以下行添加到设置 json:
"editor.defaultFormatter": "esbenp.prettier-vscode"
Már*_*lim 31
不知道为什么,但将 Default Formatter 设置为 ebsenp.prettier 对我不起作用。但我发现一个类似的命令有效。
Ste*_*art 29
我发现的最简单的方法是这样的:
右键单击要格式化的文件
选择
Format Document With ...
Run Code Online (Sandbox Code Playgroud)
您将看到不同格式化程序的下拉菜单。最终的条目将是
Configure Default Formatter...
Run Code Online (Sandbox Code Playgroud)
选择后,如果重复,您将看到默认格式化程序标记为
(default)
Run Code Online (Sandbox Code Playgroud)
Mah*_*ni. 15
default formatter并选择Prettier - Code formatterFormat on Save并勾选复选框Note: shift + alt + f也进行格式化但不保存文档。在命令面板(ctrl + shift + p)中,搜索格式,然后选择格式文档。然后选择 Prettier - Code Formatter。
注意:如果您没有看到选择默认格式的提示,您可以在“设置”中手动更改。将 Editor: Default 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。
| 归档时间: |
|
| 查看次数: |
14290 次 |
| 最近记录: |