less than 1 minute read

I recently discovered the awesome Format Files VS Code extension that allows you to format all files in your workspace. Typically you would need to open each file in Visual Studio Code and run the Format Document command manually, but with this extension you can format all files with a single command. This allows you to easily ensure all files are formatted consistently. This is especially useful if you have a large codebase and change your code formatting settings. e.g. changing your .editorconfig or .prettierrc settings, or modifying your VS Code code formatting settings.

The extension still needs to manually open each file in the editor and apply the formatting, so it can take a little while to run, but it sure beats doing it manually. I hope you find this extension as helpful as I have.

Happy coding!

Comments

Colin Carter

The marketplace page seems to imply you need to install additional language formatters for each language (e.g. C# FixFormat - C# for C#). But Visual Studio has built in formatting for most of the languages it supports. Does it work without additional downloads?

Daniel Schroeder

Hey Colin, Visual Studio comes with support for a bunch of different languages out of the box, but VS Code does not. You will typically need to install an extension to get intellisense, syntax highlighting, etc. for most languages (e.g. C#, Go, Python, PHP, PowerShell). I believe VS Code only supports JavaScript, TypeScript, HTML, and CSS out of the box. All this Format Files VS Code extension does is run the Format Files command on every file in the workspace; just as if you ran the command manually yourself from the command palette. If you haven’t installed an extension or configured a code formatter in VS Code for the given file type, it will not know how to properly format the file. So the short answer to your question is, yes, you will typically need to install an extension that supports the language of the file type you want to format.

Leave a Comment

Your email address will not be published. Required fields are marked *

Loading...