Code by rules: Make editorconfig to enforce code conventions and consistency

You can add an EditorConfig file to your project or codebase to enforce consistent coding styles for everyone that works in the codebase. EditorConfig settings take precedence over global Visual Studio text editor settings. This means that you can tailor each codebase to use text editor settings that are specific to that project. You can still set your own personal editor preferences in the Visual Studio Options dialog box. Those settings apply whenever you’re working in a codebase without an .editorconfig file, or when the .editorconfig file doesn’t override a particular setting. An example of such a preference is indent style—tabs or spaces.

EditorConfig settings are supported by numerous code editors and IDEs, including Visual Studio. It’s a portable component that travels with your code, and can enforce coding styles even outside of Visual Studio.

When you add an EditorConfig file to your project in Visual Studio, new lines of code are formatted according to the EditorConfig settings.

EditorConfig visual editor in Visual Studio for Windows

More detailed information, and syntax can be found here:

https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options

This content has 2 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

1 thought on “Code by rules: Make editorconfig to enforce code conventions and consistency”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.