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/text-spell-checker.md
+33-17Lines changed: 33 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
-
title: "Learn about the Text Spell Checker (Preview)"
3
-
description: Learn how to use the Text Spell Checker to correct misspelled words in multiple languages and to customize it to share with your dev team.
4
-
ms.date: 03/17/2023
2
+
title: "Learn about the Spell Checker (Preview)"
3
+
description: Learn how to use the Spell Checker in Visual Studio to correct misspelled words in multiple languages and to customize it to share with your dev team.
Many of the features in Visual Studio are designed to help you write the code you want, from making sure that your code compiles to helping you with code styling. Now, with the **Text Spell Checker** feature—introduced in [version 17.5](/visualstudio/releases/2022/release-notes-v17.5)—Visual Studio can even make sure your spelling is accurate.
18
+
Many of the features in Visual Studio are designed to help you write the code you want, from making sure that your code compiles to helping you with code styling. Now, with the **Spell Checker** feature—introduced in [version 17.5](/visualstudio/releases/2022/release-notes-v17.5)—Visual Studio can even make sure your spelling is accurate.
19
19
20
-
:::image type="content" source="media/vs-2022/text-spell-checker.png" alt-text="Screenshot of an example of the Text Spell Checker in action.":::
20
+
:::image type="content" source="media/vs-2022/text-spell-checker.png" alt-text="Screenshot of an example of the Spell Checker in action.":::
21
21
22
22
> [!IMPORTANT]
23
-
> This feature is still in development. It's available now in Visual Studio 2022 version 17.5, but it'll be refined in future Preview releases. For the latest update, see the [**Improving the Spell Checker**](https://devblogs.microsoft.com/visualstudio/improving-the-spell-checker/) post on the [Visual Studio Blog](https://devblogs.microsoft.com/visualstudio/).
23
+
> This feature is still in development. It's available now in Visual Studio 2022 version 17.5, but it'll be refined in future releases. For the latest news, see the [**Improving the Spell Checker**](https://devblogs.microsoft.com/visualstudio/improving-the-spell-checker/) post on the [Visual Studio Blog](https://devblogs.microsoft.com/visualstudio/).
24
24
25
-
Visual Studio automatically toggles on the Text Spell Checker feature with any C#, C++, or Markdown file. Visual Studio marks any words that it detects as misspelled words. Visual Studio also suggests alternate spellings and helps correct them. The feature even does a contextual rename when those misspellings are identifiers so that your code still compiles.
25
+
The Spell Checker is available for any C#, C++, or Markdown file. When the Spell Checker is enabled, Visual Studio marks any words that it detects as misspelled words. Visual Studio also suggests alternate spellings and helps correct them. The feature even does a contextual rename when those misspellings are identifiers so that your code still compiles.
26
26
27
27
You can turn the spell checker off or on by using the **Toggle Text Spell Checker** button on the main toolbar, or by selecting **Edit** > **Advanced** > **Toggle Text Spell Checker** command from the menu bar.
28
28
@@ -32,17 +32,20 @@ When the caret is on a spelling error, the [Quick Actions](quick-actions.md) pro
32
32
33
33
If any of the dictionaries provide spelling suggestions, Visual Studio displays them. If multiple dictionaries provide suggestions, Visual Studio groups its suggestions by dictionary. For strings and comments, choosing one of these suggestions results in a single, in-place replacement. For identifiers in a C++ or a C# document, accepting a suggestion results in a Refactor/Rename that updates all instances of the identifier to make sure the code compiles.
34
34
35
-
:::image type="content" source="media/vs-2022/text-spell-checker-multiple-dictionaries.png" alt-text="Screenshot of the Text Spelling Checker with multiple dictionaries listed.":::
35
+
:::image type="content" source="media/vs-2022/text-spell-checker-multiple-dictionaries.png" alt-text="Screenshot of the Spell Checker with multiple dictionaries listed.":::
36
36
37
37
You can also choose to ignore the spelling issue. By choosing to ignore the issue, Visual Studio creates an exclusion.dic file in your AppData directory on your local machine. After you choose to ignore a word, the spelling checker ignores it across all instances of Visual Studio.
38
38
39
39
## How does it work?
40
40
41
41
Because C#, C++, and Markdown all use English as the language for their keywords, Visual Studio typically uses the "English (United States)" or "en-us" dictionary for spell checking. Visual Studio checks the instance of Windows for the display language it's using, and if it's not "en-us", it uses that dictionary as well.
42
42
43
-
Feedback from early users of this feature informed us that developers wanted to know about errors in the documents they were currently working with. In direct response to this feedback, the spell checker scans documents that are open.
43
+
> [!NOTE]
44
+
> C# and C++ also have additional dictonaries for keywords in those languages, which prevents words like ‘namespace’ or ‘alloc’ from being flagged as misspelled words.
44
45
45
-
The following table shows some of the heuristics that the **Text Spell Checker** looks at when it scans a code document:
46
+
Feedback from early users of this feature informed us that developers only want to know about errors in the document they are currently working with. In response to that feedback, the spell checker only scans the document(s) that are active in the editor. In direct response to this feedback, the spell checker scans documents that are open.
47
+
48
+
The following table shows some of the heuristics that the **Spell Checker** looks at when it scans a code document:
46
49
47
50
| What's in the code | What Visual Studio checks | Why? |
48
51
|---------|---------|---------|
@@ -54,11 +57,11 @@ The following table shows some of the heuristics that the **Text Spell Checker**
54
57
| btnWorld | World, world | Fragments of three characters or fewer are ignored |
55
58
| helloworld | Helloworld, helloworld | No indicator to identify word boundaries |
56
59
57
-
Otherwise, Visual Studio considers the word misspelled and flags the token as a spelling error. Visual Studio displays the spelling error with a severity of "Message" in the Error List with a "SPELL" Code.
60
+
If Visual Studio finds a match for the token in any of the dictionaries it's using, the token is considered acceptable and the scan carries on. Otherwise, the token is considered misspelled and Visual Studio flags it as a spelling error.
58
61
59
62
:::image type="content" source="media/vs-2022/text-spell-checker-error-list-example.png" alt-text="Screenshot of an example of spelling errors in the Error List.":::
60
63
61
-
## How to customize the Text Spell Checker
64
+
## How to customize the Spell Checker
62
65
63
66
You can customize the spell checker so that it's optimized for a collaborative environment. As such, Visual Studio uses an [EditorConfig](create-portable-custom-editor-options.md) file for configuration so that you can control the spell checker behavior in a repository.
64
67
@@ -72,7 +75,7 @@ Here are some examples and use-case scenarios of the switches you can configure
72
75
```(Example: = en-us,fr-fr)```
73
76
74
77
> [!NOTE]
75
-
> Make sure to install the [language pack](../install/install-visual-studio.md) for any non-default language you're using to prevent Visual Studio from incorrectly flagging words as spelling errors.
78
+
> Make sure to install the [language pack](../install/install-visual-studio.md) for any language you're using to prevent Visual Studio from incorrectly flagging words as spelling errors.
76
79
77
80
- Control what Visual Studio should check. In this example, Visual Studio would check identifiers and comments for misspelled words but wouldn’t check inside strings.
78
81
@@ -84,13 +87,26 @@ Here are some examples and use-case scenarios of the switches you can configure
84
87
```spelling_error_severity = error OR warning OR information OR hint```<br>
85
88
```(Example: = error)```
86
89
87
-
- Create your own exclusion dictionary to specify words you consider to be correctly spelled. In this example, the first time the Text Spell Checker is run against any file in the solution, Visual Studio checks for an exclusion.dic file in the same directory as the .sln file (for a C# project) or in the root directory (for a C++ directory). If no exclusion.dic file exists, the Visual Studio creates one. Then, whenever the user chooses to ignore a word, Visual Studio adds it to this exclusion.dic file. Visual Studio considers any word that appears in this exclusion.dic file as a correctly spelled word.
90
+
- Create your own exclusion dictionary to specify words you consider to be correctly spelled. In this example, the first time the Spell Checker is run against any file in the solution, Visual Studio checks for an exclusion.dic file in the same directory as the .sln file (for a C# project) or in the root directory (for a C++ directory). If no exclusion.dic file exists, the Visual Studio creates one. Then, whenever the user chooses to ignore a word, Visual Studio adds it to this exclusion.dic file. Visual Studio considers any word that appears in this exclusion.dic file as a correctly spelled word.
88
91
89
92
```spelling_exclusion_path = absolute OR relative path to exclusion dictionary```<br>
90
93
```(Example: = .\exclusion.dic)```
91
94
92
-
> [!IMPORTANT]
93
-
> The exclusion.dic file must be UTF16 with BOM encoding to work correctly.
95
+
> [!NOTE]
96
+
> Visual Studio uses the exclusion dictionary specified by the spelling_exclusion_path switch in your .editorconfig file or an "exclusion.dic" file in your `%localappdata%\Microsoft\VisualStudio\<Version>` directory if a switch can’t be found.
97
+
98
+
- Control whether the language-specific exclusion dictionary so use. When set to false, any words specified in the exclusion dictionaries specific to C++ or C# won't be used. The default is true.
99
+
100
+
```spelling_use_default_exclusion_dictionary = true OR false```<br>
There are a few special behaviors in how Visual Studio checks code for spelling errors that are different from a traditional spell checker that's designed for written text. Some of these behaviors include:
106
+
107
+
- In a string that includes punctuation, for example, 'misc.", Visual Studio won't suggest a correction because punctuation in an identifier might result in code that won't compile.
108
+
- Backslashes in a string will omit the subsequent character from being spell-checked and treat the backslash and subsequent character as a word delimiter. For example, in the string `hello\nworld`, Visual Studio detects the backslash first. Visual Studio treats the `\n` as a word delimiter, which leaves "hello" and "world", each of which are checked individually.
109
+
- Strings that contain URLs such as `https://...` or `mailto:..` won't be spell-checked over the entire string.
0 commit comments