- Select
File -> Preferences -> Settings(Ctrl+comma) and search formformatter - Set Prettiers as Default formatter.

If above does not work:
ctrl+shift+p > Format Document With... > Configure Default Formatter... > Prettier - Code formatter
This also work with ctrl+shift+I
- Select
File -> Preferences -> Settings(Ctrl+comma) and search formformatter - Set Prettiers as Default formatter.

If above does not work:
ctrl+shift+p > Format Document With... > Configure Default Formatter... > Prettier - Code formatter
This also work with ctrl+shift+I
If doing what @Simin Maleki mentioned does not solve it for you, there is a chance that your default formatter is not set:
File > Preferences > Settings > Search for "default formatter"
Make sure your Editor: Default Formatter field is not null but rather Prettier - Code formatter (esbenp.prettier-vscode) and that all the languages below are ticked. This fixed my issue.
STEP BY STEP WALKTHROUGH

Also make sure that your format on save is enabled:

I got back to VScode after few months, and now Prettier is not working for me. I have tried saving the setting manually as well, but it is not working.
Prettier ver - 5.8.0
VScode ver - 1.52.1
Please help.!
Thankyou.
Follow these steps:
- CTRL + SHIFT + P
- Format Document (in pop-up bar)
- Select
Format Document - Select
Configure Default Formatter... - Select
Prettier - Code formatter
Done!
In VSCode settings, search for "Editor: Default Formatter", set it to esbenp.prettier-vscode and restart VSCode.
Update, i just find the solution if anyone is having the same problem i have to add the following lines to user setting json
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
Press Ctrl+shift+p and type Preferences: Open User Settings (JSON). In that json file add the following line and save. This should enable so vscode formats the code each time you save.
{
"editor.formatOnSave": true
}
I have installed Prettier and changed the defaults to use Prettier as per the documentation. I have turned on auto-save in VS Code therefore Prettier should work every time I make a change but it doesn't. It only works when I manually save by pressing Ctrl + S. Is this the intended behavior or am I missing something?
In VSCode, hit CTRL + SHIFT + P, write Preferences: Open User Settings (JSON) and hit enter, it will open up your settings.json:
Make sure prettier is your default formatter:
"editor.defaultFormatter": "esbenp.prettier-vscode"
you can set it for specific languages e.g: for typescript:
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
TLDR; Settings > Prettier Require Config: false / unchecked
I tried these and it still wasn't working. I noticed that at the bottom of my VS Code my Prettier wasn't showing a checkmark next to it. Clicked on "Prettier" at the bottom of the screen and it said it was skipping the file because there was not a require config set to true.
Solution was in this thread here: Prettier extension is not working in vs code Require config set to true