I've installed Prettier extension in VS Code, and when I attempt to format a file, VS Code asked me:
Do you want to format with the default formatter or with prettier formatter?
I accidentally chose the default formatter. How can I change this to format with Prettier as default?
Don't know why but setting Default Formatter to ebsenp.prettier didn't work for me. But I found a similar command that worked.
Open settings by clicking the cog in the bottom left of the vs code side bar and selecting settings from the menu, or by hitting Ctrl+,
At the top right of the settings pane, hit the open file icon (if you hover, the tooltip will read 'Open Settings (JSON)'
Add the following line to the settings json:
"editor.defaultFormatter": "esbenp.prettier-vscode"
In the command palette(ctrl + shift + p), search for format and then choose Format Document. Then choose Prettier - Code Formatter.
Note: If you do not see a prompt for selecting a default format, you can manually change this in your Settings. Set Editor: Default Formatter to ebsenp.
here is the compelete solution: 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.
The easiest method I found was this:
Right-Click on a file you wish to format
Select
Format Document With ...
You will be offered a drop-down of different formatters. The final entry will be
Configure Default Formatter...
After your selection, if you repeat, you will see the default formatter marked with
(default)
default formatter
and choose Prettier - Code formatter
Format on Save
and tick the check boxIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With