I have been searching google for several hours.
Many user have similar problem with me. https://stackoverflow.com/questions/52586965/why-does-prettier-does-not-format-code-in-vs-code/64273353#64273353
But none of the solution works for me.
https://imgur.com/2ssn1Vt
I have prettier installed. And I have tried the following
1.Command + Shift + p
2.type format document with
3.select Configure Default Formatter...
https://imgur.com/xw5oYvS
Then I cant select Prettier as default.
I only give me Python(default) as the only option.
I have a setting.json inside my root. Is it related?
https://imgur.com/KbEdsOV
Videos
So, I'm starting to learn web dev, I'm at HTML right now, and using Linux.
The problem I'm having, is no matter what I tinker with in Prettier's settings, the formatting does behaviors I don't like, that mess with my ability to check visually and compare with the video tutorial (2022) I'm using, just a single line break being added or deleted makes it look like everything and anything could be different from the source video.
These behaviors include:
Deleting line break before <head> and after </body> tags.
Indenting head and body tags, instead of just their contents.
Adding a line break inside a <li> element and indenting it because it contains a phrase having <a> and <abbr> tags, the closing </abbr> also gets a line break right before the '>' (apparently abbr tag is "breaking" because it has a period right after). ๐คฆ๐คฆ๐คฆ
I have set set the Print Width to 600 but it doesn't fix the 3rd problem.
Is there a VS Code feature that's just limited to adding indentation on format without messing with anything else? I'd like to know if there are fixes without having to disable Prettier if possible, but this is so ridiculous I may as well stop using it.
Every time I try to save my file it's not formatting it, It says it is but it is not. when I save the prettier icon on the bottom right looks like this but the console says it worked. everything has the right settings and my config file is fine, don't know what to do please help.
- 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:

Hello, I really need help, prettier just stopped working with react for no reason, as you can see it works with json files, but not react. What could be the reason? here is my settings.json:
{
"editor.bracketPairColorization.enabled": true,
"editor.accessibilitySupport": "off",
"editor.formatOnSave": true,
"typescript.updateImportsOnFileMove.enabled": "always",
"editor.inlineSuggest.enabled": true,
"github.copilot.enable": {
"*": true,
"yaml": false,
"plaintext": true,
"markdown": true
},
"window.zoomLevel": -2,
"github.copilot.advanced": {},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnPaste": true,
"[typescriptreact]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
}How can it suddenly stop working?
I have Prettier setup as the default formatter already and it's working fine for JSX and JS files.
The weird thing is that it works on save, so when I save it formats HTML correctly, but if I try to do it manually I get: "Extension 'Prettier - Code formatter' is configured as formatter but it cannot format 'HTML'-files".
I have a problem with prettier - code formatter
I installed prettier, it shows up in extensions, but when trying to use the extension in visual studio code, I can't use it.
I leave these images so you can see my problem and if you can help, I would greatly appreciate it.
Hello, I am banging my head against a wall.
For long I had no autoformatting enabled in Vscode, when eslint (or prettier - I use the eslint prettier package) complained about some styling formatting I hovered over the error and clicked "Fix all problems" in Vscode.
But then I thought I finally need to setup the fix/format on save thingyโฆ I enabled format on save in vscode settings And added this in my settings json in my project:
"editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": true },
And it works!
But it seems I have some conflicting rules or stuff. Because I have something like this: some function => {} and when I hit save it formats to add a whitespace inside the curly braces: some function => { }
And here begins my problem. With the space I get an eslint error to remove the whitespace but when saving it adds it again. I am basically stuck lol
I tried to revert the settings in vscode but it keeps happening and I have no idea where to look for to fix this issue?
I will really appreciate any help or hints.
I'm new to VS Code, and have just installed the Prettier extension so that my HTML / CSS is formatted neatly.
I've installed it, and set it as the default formatter... but still its not doing anything whenever I hit save?
I'm new to VS Code, and have just installed the Prettier extension so that my HTML / CSS is formatted neatly.
I've installed it, and set it as the default formatter... but still its not doing anything whenever I hit save?
Hey everyone, for the life of me I can't figure out why prettier won't format css. I have gone over all of my setting, format on save, setting prettier as the default format, and checked the setting.json file. Still can't figure out what is going on. Any help would be appreciated!
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.
Hi,
i'm currently learning JS from udemy, and one of the lessons is setting up my VS code with prettier. I have set the settings to Format on Save and also default formatter as prettier, but when i type in a code, and i push enter, it does not format the code unless i exit out of VS code and open it back up.
can someone tell me what i'm doing wrong please?
thanks
Guys, anybody got any experience with Prettier not working on VS Code? I've pretty much tried every solution online, including uninstalling and reinstalling Prettier and VS Code itself. I've also cleared a lot of cache as recommended somewhere and nothing changed. Prettier appears enabled and with all the correct settings activated. Any help greatly appreciated!
Do you potentially have a config file in your project root taking priority for formatting?
Try opening the output of it and see if it tells you what is wrong.
I think it is View > Output and switch it to prettier. Then try saving file / triggering it and see what it tells you.