

Visual Studio Spell Checker Preview Now Available
source link: https://devblogs.microsoft.com/visualstudio/visual-studio-spell-checker-preview-now-available/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Visual Studio Spell Checker Preview Now Available

Dante Gagne
We know developers like you take pride in your code! Many of the features in Visual Studio are designed to help you write the code you want. Visual Studio helps you ensure your code compiles and can even help with code styling. Now it can even make sure your spelling is accurate. Visual Studio 17.5 preview 3 introduces the first preview of the Spell Checker for C#, C++ and Markdown files.
The Visual Studio Spell Checker
Getting Started
The feature will be turned on automatically when working with any C#, C++ or Markdown file. Now, when you’re working with any document supported by the spell checker, Visual Studio will mark any words that detects as misspelled words. Visual Studio will also suggest alternate spellings, and help correct them, even doing a contextual rename when those misspellings are identifiers, so your code will still compile. The spell checker can be disabled by unchecking the “Text spell checker” feature under Manage Preview Features. The spell checker can also be enabled or disabled from the menu with the Edit > Advanced > Toggle Text Spell Checker command, or from a button on the main toolbar in Visual Studio.
How do you use it?
When the caret is on a spelling error, the quick actions provide solutions for fixing the spelling mistakes. You can bring up the quick actions with either “Ctrl+.” or “Alt+Enter”. When the context menu comes up, Visual Studio provides three options to handle a spelling issue.
If any of the dictionaries provide spelling suggestions, Visual Studio will provide them. If multiple dictionaries provide suggestions, the suggestions will be grouped by dictionary. For strings and comments, choosing one of these suggestions will do a single, in-place replacement. For identifiers in a C++ or a C# document, accepting a suggestion will perform a Refactor/Rename, updating all instances of the identifier to make sure the code compiles.
Suggestions when multiple dictionaries are in use
You can also choose to ignore the spelling issue. By choosing to ignore the issue, Visual Studio will create an exclusion.dic file in your AppData directory on your local machine. Once a word has been ignored, it will be ignored across all instances of Visual Studio for you.
How does it work?
If you’re interested in the details, this section will get into the specifics of how the spell checker works. Many of these behaviors can be customized, and we’ll cover that in the next section. Since C#, C++ and Markdown all use English as the language for their keywords, Visual Studio will always use the “English (United States)” or “en-us” dictionary for spell checking. Visual Studio will also ask the instance of Windows for the display language it’s using, and if it’s not “en-us”, it will use that dictionary as well.
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 will only scan documents that are open.
This chart below shows some of the heuristics that the spell checker looks at when scanning a code document:
What’s in the code | What Visual Studio checks | Why? |
Hello | Hello, hello | Always check for both proper and common nouns |
HelloWorld | Hello, hello, World, world | Medial capitals common are used to mark word boundaries |
Hello.World | Hello, hello, World, world | Punctuation is used as a word boundary |
_Hello123 | Hello, hello | Leading or trailing numbers or punctuation is stripped |
Hello2World | Hello, hello, World, world | Medial numbers, like punctuation, is used as word boundary |
btnWorld | World, world | Fragments of 3 characters or less are ignored |
helloworld | Helloworld, helloworld | No indicator to identify word boundaries |
Otherwise, we consider the word misspelled and flag the token as a spelling error. This will show up with a severity of “Message” in the Error List with a “SPELL” Code.
Spelling Errors in the Error List
Customizing the Spell Checker
The default behavior is designed to get users started and help with the initial experience. Once users are ready to start working in a collaborative environment, the spell checker has options for customizability.
We chose editorconfig for configuration to allow users to control the spell checker behavior in their repository. By configuring .editorconfig, users can establish coding standards they expect to be followed and maintain consistency that would be difficult through other methods.
Here are the switches you can configure in editorconfig:
spelling_languages = _language_[,_language_] (Example: = en-us,fr-fr)
- This lists the languages for Visual Studio to use. In this example, Visual Studio would only use the en-us and fr-fr dictionaries when checking for spelling issues. Note that the fr-fr language pack must be installed on the user’s machine or Visual Studio will incorrectly flag any French words as spelling errors.
spelling_checkable_types = strings,identifiers,comments (Example: = identifiers,comments)
- This controls what Visual Studio should check. In this example, Visual Studio would check identifiers and comments for misspelled words but wouldn’t check inside strings.
spelling_error_severity = error OR warning OR information OR hint (Example: = error)
- This controls the severity Visual Studio will assign to spelling errors in the error list. In this example, spelling errors will be displayed as errors.
spelling_exclusion_path = absolute OR relative path to exclusion dictionary. (Example: = .\exclusion.dic)
- This allows you to 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 will check 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 file exists, the spell checker will create one. Then, whenever the user chooses to ignore a word, it will be added to this exclusion.dic file. Visual Studio will consider any word that appears in this exclusion.dic file as a correctly spelled word. Note that the exclusion.dic file must be UTF16 with BOM encoding to work correctly.
What do you think?
We’re really excited to hear how the spell checker is helping developers feel better about their code. Features like these come from feedback from our community and we appreciate all the feedback. We’d love to know what you think, and we invite folks to join in the conversation over on Developer Community. Let us know what improvements you feel would help make the spell checker even better. Thanks for being an important part of the Visual Studio family!
Dante Gagne Senior Product Manager, Visual Studio
Follow
Recommend
-
79
Now it's possible to spell check camel case code in Emacs using wucuo.Setup is easy. Add (wucuo-start) into ~/.emacs, then use flyspell as usual.Flyspell could use either aspell or hunspell. N
-
46
Grammar Checker - Grammar Checker is a free online spell check tool - NEXT
-
43
The UITextChecker object can be used to spell-check a string. In this tutorial a few words will be displayed inside a Table View. When the words are selected, they will be checked for spelling, the background color will c...
-
8
Windows Tray Spell Checker Sunday, April 18, 2004 I am constantly copying text into an app such as Word, just to spell check it. I decided to build a simple spell check app that would sit on the tray and spell check wha...
-
6
Visual Studio 2022 Preview 1 now available!
-
11
Visual Studio 2022 Preview 3 now available! August 10th, 2021 Preview 3 released!We experienced some issues y...
-
12
Visual Studio 2022 Preview 4 is now available! September 14th, 2021 We are excited to announce the fourth preview release of Visual Studio 2022!...
-
6
Visual Studio for Mac 17.3 Preview 2 is now available Jordan Matthiesen
-
7
New Visual Studio 17.5 preview adds a spell checker for C#, C++, and Markdown files...
-
5
Visual Studio 2022 v17.6 Preview 2 is now available Marian Luparu
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK