Visual Studio 2017 is shipped with the new tools for managing code style settings. However, even knowing about it, I have never touched the tools as it was totally unclear how to manage these settings for different projects – my work and my personal project have different indent styles and I did not want to mix them.

Recently, I was very surprised to learn that VS 2017 supports .editorconfig out of the box, allowing to control setting per-project, by committing this file in repository. Here is an example file:

root = true

[*]
end_of_line = crlf
insert_final_newline = true
trim_trailing_whitespace = true

# 4 space indentation
[*.cs]
indent_style = space
indent_size = 4

These settings are standard not only for VS but also for many other editors, allowing to easily share the same setting across the different code editing applications.

Naming conventions and style are stored in the same file, so they are easily separable between the projects. However, these settings are not standard and will be ignored by other applications.

This feature is great and I only wish to learn about it earlier, it is definitely under-communicated.

blog comments powered by Disqus