'Unable to use Format Document tool for VSCode when coding in HTML. No problems with Python

I am using VSCode to learn web design as I have used VSCode in the past for Python. While I was coding in Python, the document format tool worked just fine, even the though I moved on to PyCharm. Now that I am using VSCode for HTML/CSS, the format tool just doesn't seem to work at all. I tried adding the prettier extension and adding it as the default format tool, but that didn't work. Beyond just reinstalling VScode, is there something I missed. Thanks.

Again, I tried adding the prettier extension to the default format tool.



Solution 1:[1]

I'm an enthusiast, hope these will help.

  • Re-install & restart VSCode
  • Check settings to see if you actually activated it
  • ...

Solution 2:[2]

The prettier extension requires a little bit of configuration to work. First you need to make sure it’s your default formatter. In the settings on the top right there will be a button for viewing settings in json format. click it then add this to the file

{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
}

Then you will probably want to format on save. Add this as well:

"editor.formatOnSave": false

That should get it working.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yongle Liu
Solution 2 Dylan L.