Update
Solution A:
Press Ctrl+Shift+P
Then type Format Document With...
At the end of the list click on Configure Default Formatter...
Now you can choose your favorite code beautifier from the list.
If Format Document With... is not available:
Open a file in Visual Studio Code (the extension of the file is not important can be .js, .html, .txt, etc...) then repeat Solution A again.
Solution B:
Windows:
go to file -> preferences -> settings
Mac:
go to code -> preferences -> settings
in the search bar tpye format,
on the left side, click on Text Editor, the very first item on the right side is Editor: Default Formatter from the dropdown you can pick any document formatter which you've installed before.

For the life of me, I cannot get VSCode to format my code like it used to. Please help. I am losing my mind.
I've googled and come up empty.
I've tried:
Reinstalling
Enable/disable various extensions
Went through ALL format settings suggested (default formatter, etc)
(This includes format on save, etc)
My code is in C#.
It worked perfectly fine until I had to refresh windows due to a separate issue. It removed all of my programs installed on C: and I had to reinstall VSCode. Since then, whenever I save, NOTHING gets formatted. It is a pain in the ass to format without it. Please help.
Edit: Reinstalled .NET, now C# formatter works but Prettier does not.. at least it's something, I guess?
An accurate depiction of my mental state.
EDIT: Came back to VS code randomly, without updating, and it resolves itself.
I am sorry, this is clearly a 'knowledge of the ancients' situation. If you got here via google, I am afraid I cannot help you.
Update
Solution A:
Press Ctrl+Shift+P
Then type Format Document With...
At the end of the list click on Configure Default Formatter...
Now you can choose your favorite code beautifier from the list.
If Format Document With... is not available:
Open a file in Visual Studio Code (the extension of the file is not important can be .js, .html, .txt, etc...) then repeat Solution A again.
Solution B:
Windows:
go to file -> preferences -> settings
Mac:
go to code -> preferences -> settings
in the search bar tpye format,
on the left side, click on Text Editor, the very first item on the right side is Editor: Default Formatter from the dropdown you can pick any document formatter which you've installed before.

If we are talking Visual Studio Code nowadays you set a default formatter in your settings.json:
// Defines a default formatter which takes precedence over all other formatter settings.
// Must be the identifier of an extension contributing a formatter.
"editor.defaultFormatter": null,
Point to the identifier of any installed extension, i.e.
"editor.defaultFormatter": "esbenp.prettier-vscode"
You can also do so format-specific:
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[sass]": {
"editor.defaultFormatter": "michelemelluso.code-beautifier"
},
Also see here.
You could also assign other keys for different formatters in your keyboard shortcuts (keybindings.json). By default, it reads:
{
"key": "shift+alt+f",
"command": "editor.action.formatDocument",
"when": "editorHasDocumentFormattingProvider && editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly"
}
Lastly, if you decide to use the Prettier plugin and prettier.rc, and you want for example different indentation for html, scss, json...
{
"semi": true,
"singleQuote": false,
"trailingComma": "none",
"useTabs": false,
"overrides": [
{
"files": "*.component.html",
"options": {
"parser": "angular",
"tabWidth": 4
}
},
{
"files": "*.scss",
"options": {
"parser": "scss",
"tabWidth": 2
}
},
{
"files": ["*.json", ".prettierrc"],
"options": {
"parser": "json",
"tabWidth": 4
}
}
]
}
How to disable automatic formatting options in vscode?
[Solved] Modify vscode code formatter (how it tidy code) with {}
Visual Studio Code is Auto Formatting even with all Settings Disabled
Hey, is there a way to extract code formatter settings from VS in order to use them in VScode ?
Videos
This started happening this morning and I have no idea why.
Visual Studio Code will format my c# code whenever I hit enter, even though I have all auto formatting disabled with every setting I can find.
Is this like a new bug or some bizarre setting controlled by a keyboard shortcut I hit on accident? Does anyone know what how to fix this?