Dotnet logo

.NET Tools

Essential productivity kit for .NET and game developers

How-To's

Integrated spell checking with ReSpeller in ReSharper and Rider

The latest builds of ReSharper 2018.2 EAP and Rider 2018.2 EAP come with the ReSpeller extension, providing spell-checking functionality out of the box. Just like with code analysis, ReSpeller scans for spelling mistakes and typos in identifiers, comments, string literals and more, and provides quick-fixes to resolve the problem. Let’s have a look!

Spell-checking in the editor

ReSpeller will look for spelling mistakes in identifiers, comments, and string literals. When it detects a potential spelling mistake or a typo, it will let us know in the same way ReSharper and Rider display other code suggestions:

Typo detected in comment

We can then invoke the Alt+Enter menu where ReSpeller gives us several options to fix our mistake: we can either fix our typo or add this word to ReSpeller’s dictionary.

Quick-fix for spelling mistakes and typos

When selecting Replace with…, ReSpeller provides us with several suggestions. By default, the best match will be selected (“parameters” in this example), but other versions are provided as well. Perhaps we meant to use the singular “parameter”? And yes, “par meters” exist – they measure Photosynthetically Active Radiation in case you wanted to know.

Fix typo using suggestions from ReSpeller dictionary

What’s nice about ReSpeller is that it automatically invokes the Rename refactoring when fixing a typo in an identifier. This ensures that our spelling correction preserves consistency across our code base. Note that in the Rename dialog, we can press Ctrl+Space to invoke code completion – or in this case, word completion.

Rename refactoring to fix a spelling mistake in an identifier

Now, where do these suggestions come from…

ReSpeller dictionaries

By default, Rider and ReSharper come with a built-in dictionary for English (United States). It uses a dictionary based on Hunspell, which means we can install other languages as well. Being a native Dutch speaker (well, Flemish), I’ve downloaded the corresponding .aff and .dic files and imported it in ReSharper’s settings:

Add Hunspell dictionary to ReSpeller

Et voila! (yes, you can add French, too, and many more languages) We now have spell checking for Dutch:

Spell checking for other languages in ReSharper and Rider

Remember that the quick-fix on a spelling mistake also showed the option Add to user dictionary? It allows us to add a custom word to ReSpeller’s dictionary. And just like with settings layers, we can choose to add that word to a dictionary on our own machine or share it with the entire team.

Add to user dictionary

Configuring ReSpeller code analysis

By default, ReSpeller is enabled in many of ReSharper’s supported languages. We can enable/disable individual inspections and change severity by searching for “typo” in the settings (under Code Inspection | Inspection Severity).

Configure ReSpeller inspection severity

There are many cases where spell checking is important or even critical. ReSharper and Rider now help detect and resolve them.

Give ReSharper 2018.2 EAP a try! Or grab the latest Rider 2018.2 EAP! We’d love to hear your feedback!

image description