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
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,8 @@ You can manually populate an EditorConfig file, or automatically generate it bas
21
21
22
22
When you add an EditorConfig file to your project in Visual Studio, only new lines of code are formatted based on the EditorConfig settings. The formatting of existing code isn't changed unless you run the **Code Cleanup** or **Format Document** commands. For more information, see [Apply code styles](../ide/code-styles-and-code-cleanup.md).
23
23
24
+
For .NET, Visual Studio provides a formatted version of the `.editorconfig` file.
25
+
24
26
::: moniker range=">= vs-2022"
25
27
:::image type="content" source="media/vs-2022/editorconfig-dotnet.png" alt-text="Screenshot that shows the .editorconfig file.":::
26
28
::: moniker-end
@@ -33,7 +35,7 @@ When you use an EditorConfig file, you can still continue to set your own person
33
35
34
36
## Code consistency
35
37
36
-
EditorConfig file settings let you maintain consistent coding styles and conventions in a codebase, regardless of the editor or IDE you use. Some coding styles you can control are indent style, tab width, end-of-line characters, and encoding. For example, if your C# codebase has a convention that indents use five space characters, documents use UTF-8 encoding, and lines ends with CR/LF, you can configure an EditorConfig file to use this convention.
38
+
EditorConfig file settings let you maintain consistent coding styles and conventions in a codebase, regardless of the editor or IDE you use. Some coding styles you can control are indent style, tab width, end-of-line characters, and encoding. For example, if your C# codebase has a convention that indents use five space characters, documents use UTF-8 encoding, and lines ends with CR/LF, you can configure an EditorConfig file to use this convention. For information on supported conventions, see [Supported settings](#supported-settings).
37
39
38
40
EditorConfig files are useful when coding conventions you use on your personal projects differ from those conventions used on your team's projects. For example, you might prefer that an indent adds a tab character in your code. However, your team might prefer that an indent adds four spaces instead. EditorConfig files resolve this problem by letting you have a configuration for each scenario.
39
41
@@ -46,7 +48,9 @@ Because an `.editorconfig` file in the codebase contains the EditorConfig settin
46
48
47
49
## Supported settings
48
50
49
-
The editor in Visual Studio supports the core set of [EditorConfig properties](https://editorconfig.org/#supported-properties):
51
+
EditorConfig supports all Visual Studio-supported languages except XML.
52
+
53
+
For each language, the editor in Visual Studio supports the core set of [EditorConfig properties](https://editorconfig.org/#supported-properties):
50
54
51
55
- indent_style
52
56
- indent_size
@@ -57,8 +61,6 @@ The editor in Visual Studio supports the core set of [EditorConfig properties](h
57
61
- insert_final_newline
58
62
- root
59
63
60
-
EditorConfig supports all Visual Studio-supported languages except XML.
61
-
62
64
For C# and Visual Basic, EditorConfig also supports [code-style rules](/dotnet/fundamentals/code-analysis/code-style-rule-options) including [language](/dotnet/fundamentals/code-analysis/style-rules/language-rules), [formatting](/dotnet/fundamentals/code-analysis/style-rules/formatting-rules), and [naming](/dotnet/fundamentals/code-analysis/style-rules/naming-rules). For example, you can specify a C# language rule regarding the use of var when defining variables. Or, you can specify a naming rule that async method names must include an "Async" suffix.
63
65
64
66
## Add and remove EditorConfig files
@@ -75,7 +77,7 @@ If there is no EditorConfig file, you can add one to the project using one of th
75
77
76
78
-[Manually add the EditorConfig file](#add-an-editorconfig-file-to-a-project).
77
79
78
-
- Use [IntelliCode for Visual Studio](/visualstudio/ide/intellicode-visual-studio) to generate an `.editorconfig` file in your solution. Right-click in Solution Explorer and choosing**Add** > **New EditorConfig (IntelliCode)** from the context menu. IntelliCode for Visual Studio infers your code styles from existing code, and then creates an EditorConfig file with your code-style preferences predefined.
80
+
- Use [IntelliCode for Visual Studio](/visualstudio/ide/intellicode-visual-studio) to generate an `.editorconfig` file in your solution. Right-click in Solution Explorer and choose**Add** > **New EditorConfig (IntelliCode)** from the context menu. IntelliCode for Visual Studio infers your code styles from existing code, and then creates an EditorConfig file with your code-style preferences predefined.
79
81
80
82
### Generate an EditorConfig from code-style settings
81
83
@@ -111,9 +113,13 @@ To add an EditorConfig file to your project or solution, follow these steps:
111
113
112
114
:::image type="content" source="media/vs-2022/editorconfig-item-templates-new.png" alt-text="Screenshot that shows EditorConfig file item templates in Visual Studio.":::
113
115
116
+
If you don't see the item template, you need to add the file manually or you can add the Intellicode version of `.editorconfig`, and then modify it for your language.
117
+
114
118
1. Select the **editorconfig File (empty)** template to add an EditorConfig file prefilled with default EditorConfig options for whitespace, code style, and naming conventions. Or, select the **editorconfig File (.NET)** template to add an EditorConfig file prefilled with default [.NET whitespace, code style, and naming conventions](/dotnet/fundamentals/code-analysis/code-style-rule-options).
115
119
116
120
A new `.editorconfig` file appears in Solution Explorer, and opens in the editor as a new tab.
121
+
122
+
For .NET, Visual Studio provides a formatted version of the file, as follows.
117
123
118
124
::: moniker range=">= vs-2022"
119
125
:::image type="content" source="media/vs-2022/editorconfig-dotnet-new.png" alt-text="Screenshot that shows the .editorconfig file in Solution Explorer and editor.":::
0 commit comments