.editorconfig support in Visual Studio 2017
March 11, 2017 by Anuraj
Visual Studio 2017 .editorconfig
This post is about .editorconfig support in Visual Studio 2017. EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs. As part of productivity improvements in Visual Studio, Microsoft introduced support for .editorconfig file in Visual Studio 2017.
Unlike earlier versions, Visual Studio 2017 comes with a coding style configuration option, which you can access from Tools > Options.
The .editorconfig file overrides this settings, which helps you to keep the coding style consistant across every one in your team.
To get started, you can create a .editorconfig file in your root directory and configure the coding style. You can find more details about the Style Settings in the docs
EditorConfig files use an INI format that is compatible with the format used by Python ConfigParser Library. EditorConfig files should be UTF-8 encoded, with either CRLF or LF line separators. Here is the format, and possible values.
Here is one I have created for the demo purposes.
In this I am enforcing 3 coding styles.
- Don’t use var, show warning.
- Use object initializer, show warning.
- Use collection initializer, show error.
The root = true
specifies this editorconfig file is the root one. And here is the output.
You must close and reopen any open files to have EditorConfig settings apply once it is added or edited.
Resources
Happy Programming :)
Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub