Stilgar
Stilgar

Reputation: 23561

Is there global .editorconfig in Visual Studio 2017

In Visual Studio 2017 we can use .editorconfig file in our project to set code style rules for the project. There is also a list of settings for Visual Studio itself presumably used when there is no editorconfig in the project. Is there a default editorconfig somewhere in Visual Studio that I can replace to set these settings rather than click through each of them?

Upvotes: 18

Views: 13366

Answers (3)

David Noreña
David Noreña

Reputation: 4230

Yes, you can do it!, and the best way to do it now is using the EditorConfig Language Service extension.

From the extension's description:

The EditorConfig Project helps developers define and maintain consistent coding styles between different editors and IDEs.

Visual Studio 2017 natively supports .editorconfig files, but it doesn't give language support for editing those files. This extension provides that.

So, you can have default settings in VS 2017 and override them using the .editorconfig file, not only in your solution but also within your solution's projects, and you can have as many .editorconfig files as you like.

Please give it a try !

Upvotes: 1

Stilgar
Stilgar

Reputation: 23561

As pointed out by @gunr2171 there is no .editorconfig file in the Visual Studio settings. However as pointed out by @Hans Passant you could work around the issue by placing an .editorconfig file in the directory where you keep your projects. Because Visual Studio looks up the directory tree to find an .editorconfig with root=true the settings will be applied even though they are outside the directory of the solution.

Upvotes: 18

gunr2171
gunr2171

Reputation: 17545

Visual Studio doesn't have a machine-level .editorconfig file, but it does have machine-level style settings. If you have a .editorconfig file in your solution it will override those particular settings.

From the VS 2017 release notes:

Building on Visual Studio's support for EditorConfig, we worked with the community to add .NET code style settings to the file format. This means that you can configure your team's code style conventions, check them into source control, and have violations appear live in the editor as developers are typing. You can see all the code style options in the Roslyn repo's .editorconfig or in the documentation. You can continue to configure your machine-specific code style settings in Tools > Options > Text Editor > [C#/Basic] > Code Style and these rules are overridden when an EditorConfig is present and conflicts.

Upvotes: 5

Related Questions