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?
An . editorconfig file appears in Solution Explorer, and it opens in the editor. Edit the file as desired.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With