Reformat All Your Files in VSCode

Here’s how you can reformat all your files in VSCode

VSCodeFormatting

Sometimes, large formatting decisions aren’t made until the middle of a project. When this happens, it’s a good idea to push all the reformatting in a single clean commit. This article will show you how to do it for various tools.

Prerequisites

All of these methods assume your project is managed in a git repo, and you have no modified or staged files.

Prettier

If you’re using prettier for your formatting, the process is simple. Run the following command:

bash
npx prettier --write .

This will reformat all the files within the current folder and all subfolders. It will obey any rules you have set up in your .prettierrc and it takes seconds.