Using EditorConfig to Maintain a Consistent Coding Style
Have you ever tried to work on someone else’s code and realized that they have completely different code formatting than you are used to? Maybe they use tabs, 2 spaces, or 4 spaces for indentation. Maybe they use underscore prefixed private member variables such as private string _name;
Wouldn’t it be nice if when you pulled down the project from source control, it also brought all of the code formatting styles with it? That’s what EditorConfig is meant for.
Not long ago I added an .editorconfig
file to RogueSharp. I recently mapped all of the ReSharper settings to the config as both Visual Studio and ReSharper come bundled with native support for EditorConfig.
Download
First you’ll need to download the file. I created a public Github Gist which is available here:
- https://gist.github.com/FaronBracy/155d8d7ad98b4ceeb526b9f47543db1b
Add to Solution
- Copy the downloaded file to the root of your solution where the .sln file lives.
- Make sure that the name is
.editorconfig
- Create a new Solution Items folder in Visual Studio if it doesn’t already exist
- Add
.editorconfig
to the Solution Items folder

Modify Settings
Although the .editorconfig
will work as is, you’ll likely want to make some modifications to it, to match your coding style.
Common Settings
- tabs vs spaces
- indent size
- trim trailing whitespace

You’ll likely want to change the indent size at a minimum. At TechSmith where I am currently employed we use 3 spaces, but 2 or 4 is more typical.
.NET Language Conventions

Microsoft Documentation For .NET Language Conventions

Microsoft Documentation For .NET Formatting Conventions
.NET Naming Conventions

Microsoft Documentation For .NET Naming Conventions
ReSharper Settings

JetBrains Documentation For ReSharper EditorConfig Settings
Note: I organized the ReSharper settings according to how they appear in the menus. There should be a 1-1 relationship between each .editorconfig
setting and it’s corresponding ReSharper menu entry.

About Faron
Faron Bracy is a husband, father, and TechSmith employee. He maintains the open source library RogueSharp as a hobby project. Other hobbies include painting fantasy miniatures, playing board games, and playing retro video games with his family.