In this categoryVS Code Setup ยท 25
- How to Set Up GitHub Copilot in VS CodeStart
- How to Use Copilot Chat and Inline Chat in VS Code
- How to Install and Manage Extensions in VS Code
- How to Install the Continue Extension in VS Code
- How to Install Cline, the Autonomous Coding Agent, in VS Code
- How to Configure Continue with an API Model
- How to Set Up an AI Assistant in VS Code
- How to Run Continue with a Local Model Using Ollama
- How to Run Copilot, Continue, and Cline Together Without Conflicts
- How to Add an MCP Server to Cline
- How to Fix AI Suggestions Not Appearing in VS Code
- How to Install and Trust an AI Extension in VS Code
- How to Install a VS Code Extension from the Command Line
- How to Create a launch.json to Debug a Node.js App in VS Code
- How to Initialize a Git Repository in VS Code
- How to Stage, Commit, and Push Changes from VS Code
- How to Debug a Browser App in VS Code with the Built-in Chrome Debugger
- How to Resolve Git Merge Conflicts in VS Code
- How to Run Build and Dev Commands with tasks.json in VS Code
- How to Add Environment Variables to a VS Code Debug Configuration
How to Set Up Format on Save with Prettier in VS Code
Install the Prettier extension, make it your default formatter, and have VS Code auto-format your code every time you save.
Consistent formatting keeps diffs clean and stops pointless arguments about spacing, which matters even more when an AI assistant writes chunks of your code. Prettier formats your files automatically against one shared style. With format on save turned on, you never think about it again. This guide wires it up end to end.
What you need
- VS Code installed
- A JavaScript, TypeScript, CSS, or similar project open
- Internet access to install an extension
Step 1: Install the Prettier extension
Open the Extensions view with Ctrl+Shift+X. Search for Prettier - Code formatter, published by Prettier. Click Install. This is the extension that lets VS Code run Prettier on your files.
Step 2: Set Prettier as the default formatter
Open settings.json (Command Palette, then Open User Settings (JSON)) and set the default formatter to Prettier, then turn on format on save. The value esbenp.prettier-vscode is the extension's id.
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}Step 3: Add a project config (optional)
To pin the style for a whole team, add a .prettierrc file to the project root. Anyone who opens the project gets the same rules. Without this file Prettier uses sensible defaults.
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
}Step 4: Test it
Open any supported file, mangle the spacing on purpose, then save with Ctrl+S. Prettier instantly reformats the file to the correct style. If nothing happens, check the next tip.
Result
Every time you save, your code snaps to a single consistent style. Manual spacing fixes and formatting nitpicks in code review disappear.
Watch related tutorials
1:42:18
28:14
41:09
9:47
8:23
12:36New guides in your inbox
Fresh step-by-step how-to guides as we publish them. One email a week, no more.