Install Prettier
Install the "Prettier - Code formatter" extension from the extensions sidebar. Once this is complete, open a code file and press Alt + Shift + F to auto format it. You should see a prompt asking you to choose which code formatter you would like to use since you now have two available. Select Prettier from the prompt.

Enable formatting on save for all files
Open the settings menu via "File > Preferences > Settings". Type editor.formatonsave into the search bar and enable the "Format On Save" setting. Now, whenever you save any file it should be formatted automatically.

Enable formatting on save for only certain file types
Open the settings.json file by navigating to "File > Preferences > Settings" and clicking the "Open Settings (JSON)" button at the top right of the screen.

Search the file for any preexisting "editor.formatOnSave" setting and delete it. Then add the following, replacing "javascript" with whatever language you want to enable format on save for.
"editor.formatOnSave": false,
"[javascript]": {
"editor.formatOnSave": true
}
Answer from Alex Myers on Stack OverflowVideos
For those trying to quickly change Prettier settings for VS Code. Here are the steps:
- Go to FILE -> PREFERENCES -> SETTINGS. (VS Code Menus)
- Settings window should open. Above (Top) there is a search. Type "Prettier"
- You should see the available Prettier settings. You can modify them :)
The new way to configure prettier settings:
- at the root of your project folder, create a new config file (I'd suggest calling it either
.prettierrc.jsonor just.prettierrc) - in that new file, add json custom settings: my go-to settings for JS are as follows:
{
"trailingComma": "none",
"tabWidth": 4,
"semi": true,
"singleQuote": true
}
I'd suggest doing this in each of your projects and including in any source control, that way every pull of the repo will automatically set some base settings for that developer's instance of prettier.