You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ide/create-portable-custom-editor-options.md
+16-12Lines changed: 16 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,9 @@ In Visual Studio 2017, you can add an [EditorConfig](http://editorconfig.org/) f
19
19
20
20
EditorConfig settings are supported by numerous code editors and IDEs, including Visual Studio. It's a portable component that travels with your code, and can enforce coding styles even outside of Visual Studio.
21
21
22
+
> [!NOTE]
23
+
> When you add an EditorConfig file to your project in Visual Studio, the formatting of existing code is not changed unless you format the document (**Edit** > **Advanced** > **Format Document** or **Ctrl**+**K**, **Ctrl**+**D**). However, any new lines of code are formatted according to the EditorConfig settings.
24
+
22
25
## Coding consistency
23
26
24
27
Settings in EditorConfig files enable you to maintain consistent coding styles and settings in a codebase, such as indent style, tab width, end of line characters, encoding, and more, regardless of the editor or IDE you use. For example, when coding in C#, if your codebase has a convention to prefer that indents always consist of five space characters, documents use UTF-8 encoding, and each line always ends with a CR/LF, you can configure an .editorconfig file to do that.
@@ -44,7 +47,7 @@ EditorConfig editor settings are supported in all Visual Studio-supported langua
44
47
45
48
## Adding and removing EditorConfig files
46
49
47
-
Adding an EditorConfig file to your project or codebase does not convert existing styles to the new ones. For example, if you have indents in your file that are formatted with tabs, and you add an EditorConfig file that indents with spaces, the indent characters are not converted to spaces. However, any new lines of code will be formatted according to the EditorConfig file.
50
+
Adding an EditorConfig file to your project or codebase does not convert existing styles to the new ones. For example, if you have indents in your file that are formatted with tabs, and you add an EditorConfig file that indents with spaces, the indent characters are not automatically converted to spaces. However, any new lines of code are formatted according to the EditorConfig file. Additionally, if you format the document (**Edit** > **Advanced** > **Format Document** or **Ctrl**+**K**, **Ctrl**+**D**), the settings in the EditorConfig file are applied to existing lines of code.
48
51
49
52
If you remove an EditorConfig file from your project or codebase, you must close and reopen any open code files to revert to the global editor settings for new lines of code.
50
53
@@ -64,16 +67,16 @@ If you remove an EditorConfig file from your project or codebase, you must close
64
67
65
68
1. Edit the file as desired, for example:
66
69
67
-
```EditorConfig
68
-
root = true
70
+
```EditorConfig
71
+
root = true
69
72
70
-
[*.{cs,vb}]
71
-
indent_size = 4
72
-
trim_trailing_whitespace = true
73
+
[*.{cs,vb}]
74
+
indent_size = 4
75
+
trim_trailing_whitespace = true
73
76
74
-
[*.cs]
75
-
csharp_new_line_before_open_brace = methods
76
-
```
77
+
[*.cs]
78
+
csharp_new_line_before_open_brace = methods
79
+
```
77
80
78
81
Alternatively, you can install the [EditorConfig Language Service extension](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.EditorConfig). After you install this extension, simply choose **Add** > **.editorconfig File** from the right-click or context menu of the solution node, project node, or any folder in Solution Explorer.
79
82
@@ -87,7 +90,7 @@ To override some or all of the EditorConfig settings, add an .editorconfig file
If you just want to override some but not all of the settings, simply specify those settings in the .editorconfig file. Only those properties that you explicitly list in the lower-level file will be overridden. Other settings from higher-level .editorconfig files will continue to apply. If you want to ensure that _no_ settings from _any_ higher-level .editorconfig files are applied to this part of the codebase, add the ```root=true``` property to the lower-level .editorconfig file:
93
+
If you want to override some but not all of the settings, specify just those settings in the .editorconfig file. Only those properties that you explicitly list in the lower-level file are overridden. Other settings from higher-level .editorconfig files continue to apply. If you want to ensure that _no_ settings from _any_ higher-level .editorconfig files are applied to this part of the codebase, add the ```root=true``` property to the lower-level .editorconfig file:
91
94
92
95
```EditorConfig
93
96
# top-most EditorConfig file
@@ -118,7 +121,7 @@ As expected, pressing the **Tab** key on the next line indents the line by addin
118
121
119
122

120
123
121
-
We'll add a new file called .editorconfig to the project, with the following contents. The `[*.cs]` setting means that this change applies only to C# code files in the project.
124
+
Add a new file called .editorconfig to the project, with the following contents. The `[*.cs]` setting means that this change applies only to C# code files in the project.
122
125
123
126
```EditorConfig
124
127
# Top-most EditorConfig file
@@ -139,7 +142,7 @@ If there is an EditorConfig file anywhere in the directory structure at or above
139
142
140
143
**"User preferences for this file type are overridden by this project's coding conventions."**
141
144
142
-
This means that if any editor settings in **Tools**, **Options**, **Text Editor** (such as indent size and style, tab size, or coding conventions) are specified in an EditorConfig file at or above the project in the directory structure, the conventions in the EditorConfig file override the settings in Options. You can control this behavior by toggling the **Follow project coding conventions** option in **Tools**, **Options**,**Text Editor**. Unchecking the option turns off EditorConfig support for Visual Studio.
145
+
This means that if any editor settings in **Tools** > **Options** > **Text Editor** (such as indent size and style, tab size, or coding conventions) are specified in an EditorConfig file at or above the project in the directory structure, the conventions in the EditorConfig file override the settings in Options. You can control this behavior by toggling the **Follow project coding conventions** option in **Tools** > **Options** >**Text Editor**. Unchecking the option turns off EditorConfig support for Visual Studio.
Copy file name to clipboardExpand all lines: docs/ide/editorconfig-naming-conventions.md
+3-5Lines changed: 3 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,21 @@
1
1
---
2
-
title: ".NET Naming Conventions For EditorConfig | Microsoft Docs"
2
+
title: ".NET Naming Conventions For EditorConfig files | Microsoft Docs"
3
3
ms.custom: ""
4
4
ms.date: "11/20/2017"
5
5
ms.reviewer: ""
6
6
ms.suite: ""
7
-
ms.tgt_pltfrm: ""
8
7
ms.topic: "article"
9
8
helpviewer_keywords:
10
9
- "naming conventions [EditorConfig]"
11
10
- "EditorConfig naming conventions"
12
11
author: "gewarren"
13
12
ms.author: "gewarren"
14
13
manager: ghogen
15
-
ms.technology:
16
-
- "vs-ide-general"
14
+
ms.technology: vs-ide-general
17
15
ms.workload:
18
16
- "multiple"
19
17
---
20
-
# Naming Conventions for EditorConfig
18
+
# .NET naming conventions for EditorConfig
21
19
22
20
Naming conventions concern the naming of code elements such as classes, properties, and methods. For example, you can specify that public members must be capitalized, or that asynchronous methods must end in "Async". You can enforce these rules by specifying them in an [.editorconfig file](../ide/create-portable-custom-editor-options.md). Naming rule violations appear either in the Error List or as a suggestion under the name, depending on the severity you choose for your rule. There is no need to build the project in order to see violations.
0 commit comments