A VS Code extension that allows you to toggle the formatter (Prettier, Beautify, …) ON and OFF with a simple click.
In the command palette (CMD + SHIFT + P
) select “Install Extension” and choose “Formatting Toggle”.
The extension should show up on the right side of the status bar. Simply click it to toggle the formatter ON and OFF. Alternatively, in the command palette (CMD + SHIFT + P
), run the “Toggle Formatting” command.
By default, Formatting Toggle toggles the formatter for all formatting events: formatOnPaste
, formatOnSave
and formatOnType
. To ignore one of these and leave the value that is defined in your settings unchanged, you can use the formattingToggle.affects
setting in your editor settings (Code > Preferences > Settings).
{
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"formattingToggle.affects": ["formatOnSave"]
}
{
"editor.formatOnType": false,
"formattingToggle.affects": ["formatOnPaste", "formatOnSave"]
}
Note: this was the default behaviour before version 2.0.0 of the extension.
{
"formattingToggle.affects": ["formatOnPaste", "formatOnSave", "formatOnType"]
}