Toggle Auto Format On Save with Prettier in VSCode

Viewed 6363

99% of the time I want VSCode to auto format my files on save with Prettier. For that 1% of the time is there a way to toggle this to off in a way that's quicker than going into the settings and then manually switching it on and off?

I've tried looking for any keyboard bindings but the only one I found was prettier.open-output

2 Answers

I switched from Atom where my prettier extension had a toggle in the menu bar at the bottom of the editor to turn formatting-on-save on or off.

To add this to VS Code, I installed this extension: https://marketplace.visualstudio.com/items?itemName=tombonnike.vscode-status-bar-format-toggle

Once you install it you will see this in the bottom menu bar: prettier formatting toggle extension turned on

When the check mark is there, prettier will format on save if you have that enabled in your VS Code settings under Text Editor --> Formatting.

Once you have a file that you don't want prettier to format, for example when reviewing someone else's code, you can turn off auto-formatting which looks like this: prettier formatting toggle extension turned off

Related