Setting up Prettier in Visual Studio Code

Here's how to set up Prettier to reformat your files on save.

First install the plugin by clicking the link at https://github.com/prettier/prettier-vscode. If VSC is installed, it'll handle the link and open the plugin page in VSC.

Once installed, open VSC's settings page, and enable reformatting on save/paste/type.

Finally, I had one issue where files wouldn't get reformatted. The reason is there were two formatters and VSC didn't know which one to use: VSC's default formatter, and the newly installed Prettier.

To make VSC ask you which to use, I had to right click a file, and force it to format: right click, format document. That's when it asked me which one to use by default.

After choosing Prettier, it started reformatting automatically.