Do you keep your code consistent using .editorconfig?

Last updated by Brady Stroud [SSW] 10 months ago.See history

It's important that the code in a project is kept consistent. This is hard to do when you have developers working in different environments.

Using a .editorconfig file is the best way to manage this.

See the EditorConfig file specification

Most IDEs will automatically find and use a .editorconfig file to format code.

See Keep your code clean, automatically!.

vs2022 add editorconfig
Good example - Project using a ".editorconfig" file

vs 2022 stylecop
Bad example - Project using StyleCop (old)

Creating .editorconfig files

In VS 2022

  1. Open the Add New Item dialog (Ctrl+Shift+A)
  2. Search for "EditorConfig"
  3. Select a config file depending on your project

vs2022 add editorconfig
Figure: Creating .editorconfig in VS 2022


  1. Create a new file called .editorconfig at the root of your project
  2. Add styling rules based on your needs

Ensuring compliance

To ensure your team is following this standard, you can add it to your Definition of Done.

Additionally, you can have a PR check that enforces .editorconfig rules, but its always better to do this locally.

Learn more on:

We open source. Powered by GitHub