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/code-styles-and-code-cleanup.md
+13-7Lines changed: 13 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ To add an EditorConfig file, see [Ways to add an EditorConfig file](../ide/creat
36
36
::: zone-end
37
37
38
38
::: zone pivot="programming-language-dotnet,programming-language-dotnetf"
39
-
For more information on .NET code style settings, see [Code style settings](/dotnet/fundamentals/code-analysis/code-style-rule-options).
39
+
For reference information on .NET code style settings, see [Code style settings](/dotnet/fundamentals/code-analysis/code-style-rule-options).
40
40
::: zone-end
41
41
42
42
::: zone pivot="programming-language-cpp"
@@ -88,16 +88,18 @@ Each item in the list shows a preview of the preference when you select the opti
88
88
89
89
::: moniker-end
90
90
91
-
Options set in this window are applicable to your Visual Studio personalization account and aren't associated with a particular project or codebase. In addition, they aren't enforced at build time, including in continuous integration (CI) builds. If you want to associate code style preferences with your project and have the styles enforced during build, specify the preferences in an [.editorconfig file](#code-styles-in-editorconfig-files) that's associated with the project.
91
+
Options set in this window are applicable to your Visual Studio personalization account and aren't associated with a particular project or codebase. In addition, they aren't enforced at build time, including in continuous integration (CI) builds. If you want to associate code style preferences with your project and have the styles enforced during build, specify the preferences in an [EditorConfig file](#code-styles-in-editorconfig-files) that's associated with the project.
92
92
93
93
### Preference and severity
94
94
95
-
For each code style setting on the **General** and **Naming** options page, you can set the **Preference** and **Severity** values using the drop-downs on each line. Severity can be set to **Refactoring Only**, **Suggestion**, **Warning**, or **Error**.
95
+
For each code style setting on the **General** and **Naming** options pages, you can set the **Preference** and **Severity** values using the drop-downs on each line. Severity can be set to **Refactoring Only**, **Suggestion**, **Warning**, or **Error**.
96
96
97
-
-All code style preferences determine the [Quick Actions](../ide/quick-actions.md) for a code style. The **Quick Actions** light bulb :::image type="icon" source="media/light-bulb-dropdown.png":::, error light bulb :::image type="icon" source="media/error-bulb.png":::, or screwdriver :::image type="icon" source="media/screwdriver.png"::: icon appears when a non-preferred style is used, and you can choose an option on the **Quick Actions** list to automatically rewrite code to the preferred style.
97
+
-Code style preferences in the **General** and **Naming** options pages determine the [Quick Actions](../ide/quick-actions.md) for a code style. The **Quick Actions** light bulb :::image type="icon" source="media/light-bulb-dropdown.png":::, error light bulb :::image type="icon" source="media/error-bulb.png":::, or screwdriver :::image type="icon" source="media/screwdriver.png"::: icon appears when a non-preferred style is used, and you can choose an option on the **Quick Actions** list to automatically rewrite code to the preferred style.
98
98
- If you want the violation to appear only as a Quick Action and also be excluded from code cleanup, set the **Severity** to **Refactoring Only**.
99
99
- If you want the violation to appear in the Error List window as well as Quick Actions, and be included in code cleanup, set the **Severity** to **Suggestion**, **Warning**, or **Error**. Violations appear as a suggestion (message), warning, or error when you set the output in the Error List window to **Build + IntelliSense**. They are excluded from **Build** only output.
100
100
101
+
Settings in an EditorConfig file take precedence over code styles set in these pages.
102
+
101
103
## Enforce code styles on build
102
104
103
105
Starting in Visual Studio 2019 version 16.8, which includes the .NET 5.0 RC2 SDK, you can [enforce the .NET coding conventions on build](/dotnet/fundamentals/productivity/code-analysis#code-style-analysis) for all .NET projects. At build time, .NET code style violations will appear as warnings or errors with an "IDE" prefix. This enables you to strictly enforce consistent code styles in your codebase.
@@ -119,7 +121,7 @@ When you change a code style in the Options page or add an EditorConfig file to
119
121
120
122
::: moniker range=">=vs-2022"
121
123
122
-
To apply code styles from an EditorConfig file or from the **Code Style** options page, use the **Code Cleanup** button at the bottom of the editor (keyboard: **Ctrl**+**K**, **Ctrl**+**E**). If an *.editorconfig* file exists for the project, those are the settings that take precedence.
124
+
To apply code styles from an EditorConfig file or from the **Code Style** options page, use the **Code Cleanup** button at the bottom of the editor (keyboard: **Ctrl**+**K**, **Ctrl**+**E**). If an EditorConfig file exists for the project, those are the settings that take precedence.
123
125
124
126
::: zone pivot="programming-language-dotnet,programming-language-dotnetf"
125
127
> [!TIP]
@@ -132,6 +134,10 @@ To apply code styles:
132
134
133
135

134
136
137
+
::: zone pivot="programming-language-dotnet,programming-language-dotnetf"
138
+
For a mapping of .NET code cleanup fixers to .NET code style rules, see [.NET code cleanup settings](#net-code-cleanup-settings).
139
+
::: zone-end
140
+
135
141
::: zone pivot="programming-language-cpp"
136
142
C/C++ options include C++ in the name of the fixer.
137
143
::: zone-end
@@ -152,7 +158,7 @@ To apply code styles:
152
158
153
159
::: moniker range="vs-2019"
154
160
155
-
For C# code files, Visual Studio has a **Code Cleanup** button at the bottom of the editor (keyboard: **Ctrl**+**K**, **Ctrl**+**E**) to apply code styles from an EditorConfig file or from the **Code Style** options page. If an *.editorconfig* file exists for the project, those are the settings that take precedence.
161
+
For C# code files, Visual Studio has a **Code Cleanup** button at the bottom of the editor (keyboard: **Ctrl**+**K**, **Ctrl**+**E**) to apply code styles from an EditorConfig file or from the **Code Style** options page. If an EditorConfig file exists for the project, those are the settings that take precedence.
156
162
157
163
> [!TIP]
158
164
> Rules configured with a severity of **None** don't participate in code cleanup but can be individually applied via the **Quick Actions and Refactorings** menu.
@@ -179,7 +185,7 @@ To apply code styles:
179
185
::: zone pivot="programming-language-dotnet,programming-language-dotnetf"
180
186
## .NET code cleanup settings
181
187
182
-
Most of the code cleanup settings map to one or more .NET code styles supported in *.editorconfig*. For examples that show the effects of the settings, use the links in the following table.
188
+
Most of the code cleanup settings map to one or more .NET code styles supported in EditorConfig. For examples that show the effects of the settings, use the links in the following table.
Copy file name to clipboardExpand all lines: docs/ide/create-portable-custom-editor-options.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
---
2
2
title: Define consistent coding styles with EditorConfig
3
3
description: Add an EditorConfig file to your project or codebase to enforce consistent coding styles for everyone that works in the codebase.
4
+
ms.date: 05/08/2025
4
5
author: mikejo5000
5
6
ms.author: mikejo
6
7
manager: mijacobs
7
8
ms.subservice: general-ide
8
9
ms.topic: how-to
9
10
helpviewer_keywords:
10
11
- editorconfig [Visual Studio]
11
-
ms.date: 05/08/2025
12
12
13
13
#customer intent: As a developer, I want to use EditorConfig files to enforce coding style consistency for everyone that writes code in our Visual Studio codebase and projects.
0 commit comments