false as an argument.
Signature
Parameters
If
true (default), formats code in all three editors. If false, formats only the currently active editor.Returns
A promise that resolves when the code formatting is complete.
Usage
Format All Editors
Format Active Editor Only
Format with Custom Settings
The formatter respects the configuration settings for code style:Formatter Configuration
The following configuration properties affect code formatting:useTabs- Use tabs instead of spaces (default:false)tabSize- Number of spaces per indentation level (default:2)semicolons- Use semicolons in JavaScript/TypeScript (default:true)singleQuote- Use single quotes instead of double quotes (default:false)trailingComma- Use trailing commas (default:true)
Notes
- Not all languages support formatting. The formatter uses Prettier which supports HTML, CSS, JavaScript, TypeScript, JSON, Markdown, and many other languages.
- Formatting is performed client-side in the browser.
- If the playground is not yet loaded, calling this method will load it first.
Related Methods
getConfig()- Get current configuration including formatter settingssetConfig()- Update formatter configuration