- Mastering Visual Studio 2017
- Kunal Chowdhury
- 555字
- 2021-07-15 17:26:34
Editor config
Editor config helps developers define and maintain consistent coding styles between different editors and/or IDEs. Microsoft has added support of Editor config in Visual Studio 2017.
The default text editor settings in Visual Studio applies to all projects of a given type. For example, if you change a C# or VB.NET text editor's settings, those settings will apply to all C# projects and VB.NET projects respectively. However, in general, the coding conventions that you use in your personal projects may differ from those used in your team's projects.
Here comes the Editor Config that enables you to do this on a per project basis and/or per folder level. In this case, the settings are contained in a .editorconfig file added to your code base. As the settings are contained in a file in the code base, they travel along with the code base:

The Editor Config doesn't support a full set of C# formatting rules and, hence, it's not a replacement for format settings in Visual Studio. Currently, it supports the following settings only in Visual Studio 2017:
- indent_style
- indent_size
- tab_width
- end_of_line
- charset
- root
- trim_trailing_whitespace
- insert_final_newline
- Code style conventions
You can create an editor configuration file at the project level or at any folder level. When you add it to the project's root level, its settings are applied across all the files in the project. If you add it to any specific folder level inside the project, the root settings will be overridden and will apply to all applicable files at that level and below.
To create an Editor Config (.editorconfig) file, right-click on a project or folder where you want to apply the settings, and then, from the context menu, click on Add | New Item..., as shown in the following screenshot:

Now, from the Add New Item dialog box, select the Text File template and give it a name, for example, .editorconfig, as shown in the following screenshot, to add the file. Note that the file name only consists of the extension of the file:

The .NET code style settings allow you to enforce the style that you want to use in your code base. Depending on the severity set in the Editor Config, it can show you a suggestion, a compiler warning, or compiler error. This can be written in the following fashion:
options_name = false|true : none|suggestion|warning|error
The option must specify true (preferable) or false; a colon, :, and a severity of none, suggestion, warning, or error. The default is none.
If you set the severity as none, it will not show anything to the user when this style is not being followed. If you set it as a suggestion, it will show a suggestion (underlying dots on the first two characters) when the style is not being followed. In case of warning or error, it will either show compiler warning or compiler error if the code does not match the style being applied to it.
- Learning NServiceBus(Second Edition)
- JavaScript百煉成仙
- 自己動手實現Lua:虛擬機、編譯器和標準庫
- R語言數據可視化之美:專業圖表繪制指南
- 名師講壇:Java微服務架構實戰(SpringBoot+SpringCloud+Docker+RabbitMQ)
- Python完全自學教程
- 移動界面(Web/App)Photoshop UI設計十全大補
- 基于Struts、Hibernate、Spring架構的Web應用開發
- 零基礎學C語言程序設計
- Android Development Tools for Eclipse
- SpringBoot從零開始學(視頻教學版)
- Modular Programming with JavaScript
- Go Systems Programming
- C語言王者歸來
- PHP高性能開發:基礎、框架與項目實戰