Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 990
Stilgar Avatar asked Mar 10 '17 21:03

Stilgar


People also ask

Where is .EditorConfig located?

An . editorconfig file appears in Solution Explorer, and it opens in the editor. Edit the file as desired.

How do I enforce coding standards in visual studio?

Use an EditorConfig file when you want to enforce coding styles for all contributors to your repo or project. You can manually populate your EditorConfig file, or you can automatically generate the file based on the code style settings you've chosen in the Visual Studio Options dialog box.

What is a .EditorConfig file?

The EditorConfig project consists of a file format for defining coding styles and a collection of text editor plugins that enable editors to read the file format and adhere to defined styles. EditorConfig files are easily readable and they work nicely with version control systems.

Does VSCode support EditorConfig?

EditorConfig for Visual Studio Code. This plugin attempts to override user/workspace settings with settings found in . editorconfig files. No additional or vscode-specific files are required.


2 Answers

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.

like image 120
Stilgar Avatar answered Oct 08 '22 06:10

Stilgar


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.

like image 33
gunr2171 Avatar answered Oct 08 '22 06:10

gunr2171