Search code examples
visual-studiocode-formattingvisual-studio-2017editorconfig

How Can I Share Visual Studio 2017 Code Style and Formatting?


My team wants to share our code styling and formatting. We've been using Resharper for this and wanted to take advantage of the new native features in VS2017! What is the best way to do this?


Solution

  • .editorconfig!

    Visual Studio 2017 will now respect settings from a .editorconfig file if it exists on disk, up to the project root. Currently this is supported on a per-project basis, not on a solution level (I believe R# may have supported this in the solution folder).

    Almost every editor in VS should support basic editorconfig options, such as:

    • indent_style
    • indent_size
    • tab_width
    • end_of_line

    Additionally, some languages also provide support for language-specific style guidelines. For .NET, see here.

    Specifically for C# or VB, if you've configured your settings in VS Tools-> Options, there is also an option to generate an .editorconfig file capturing those settings:

    Tools -> Options -> Text Editor -> C# -> Code Style, showing the button to generate .editorconfig settings