VS Code

To enable Prettier on save in Visual Studio Code

Install Prettier Extension:

  1. Open VS Code and go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window.
  2. Search for "Prettier - Code formatter" and install it.

Set Prettier as Default Formatter:

  1. Open the Command Palette by pressing Ctrl + Shift + P (or Cmd + Shift + P on Mac).
  2. Type and select Preferences: Open Settings (JSON).
  3. Add the following lines to your settings.json file:

"editor.defaultFormatter": "esbenp.prettier-vscode",

"editor.formatOnSave": true

Leave a Comment