Search code examples
htmlcssvisual-studio-codecode-formattingprettier

Why Prettier code formatter stopped formatting in VS Code?


I am trying to format the code but the prettier isn't working fine with VS code. I also tried to reinstall it but the same problem occurs. I am not able to format my html css code with prettier. You can also see the screenshot where the code is not formatted after saving the code.

enter image description here


Solution

  • Follow these steps carefully, and I think it is gonna work. First, make sure you install Prettier from the extensions store:

    enter image description here

    Then edit the settings.json file and paste in it the lines below. You can find settings.json this way:

    • On Windows: F1 or Ctrl + Shift + P, then type open settings and choose Open Settings (JSON)
    • On MacOS: Shift + CMD + P, then the same steps as Windows
    { 
    
      "editor.formatOnSave": true,
      "editor.defaultFormatter": "esbenp.prettier-vscode",
      
    }
    

    And finally, restart VS Code.