Offline Spell Checker
This extension is a spell checker that uses a local dictionary for offline usage. hunspell-spellchecker is used to load hunspell formatted dictionaries. Errors are highlighted, and hovering over them will show possible suggestions. The
suggest function was modified according to [https://github.com/GitbookIO/hunspell-spellchecker/pull/7] to speed up word suggestions.
This extension can be found on the VSCode Marketplace.
Once errors are highlighted, there are several ways to view word suggestions.
Hover over the error:
F8 to step through errors:
You can correct the error by clicking on the Quick Fix (light bulb) icon.
You can configure the operation of this extension by editing settings in
File > Preferences > Settings.
The following settings can be changed:
spellchecker.language: supported languages are:
- English (
- French (
- Greek (
- Spanish (
- Swedish (
spellchecker.ignoreWordsList: an array of strings that contain the words that will not be checked by the spell checker
spellchecker.documentTypes: an array of strings that limit the document types that this extension will check. Default document types are
spellchecker.ignoreFileExtensions: an array of file extensions that will not be spell checked
spellchecker.checkInterval: number of milliseconds to delay between full document spell checks. Default: 5000 ms.
spellchecker.ignoreRegExp: an array of regular expressions that will be used to remove text from the document before it is checked. Since the expressions are represented in the JSON as strings, all backslashes need to be escaped with three additional backslashes, e.g.
"/\\\\s/g". The following are examples provided in the example configuration file:
"/\\\\(.*\\\\.(jpg|jpeg|png|md|gif|JPG|JPEG|PNG|MD|GIF)\\\\)/g": remove links to image and markdown files
"/((http|https|ftp|git)\\\\S*)/g": remove hyperlinks
"/^(```\\\\s*)(\\\\w+)?(\\\\s*[\\\\w\\\\W]+?\\\\n*)(```\\\\s*)\\\\n*$/gm": remove code blocks
spellchecker.emitErrors: Emit errors instead of warnings for spelling mistakes
Additional sections are already removed from files, including:
- YAML header for pandoc settings
- Pandoc citations
- Inline code blocks
- Email addresses
Benchmarks (sort of)
A 397-line document was used to test the functionality. This was a conference paper that I recently wrote using Pandoc (citeproc and crossref). Simple space separation results in 5134 words. Here are some of the processing times as functionality was added. These were measured using
new Date().getTime() so results were not consistent.
- Initial test: 1.577 minutes
- Added suggestion dictionary for suggestions that have already been processed: 1.0507 minutes
- Removed YAML settings at the beginning of the document (Pandoc settings): 0.841 minutes
- Removed inline citations: 0.50695 minutes
- Removed inline image links: 0.2913 minutes
- Words of length >= 4: 13.931 seconds
Rechecking the document during edits happens much faster ( < 1 sec ).
This same document was checked on a newer computer ( Razer Blade Stealth vs. 4 year old Sony Vaio VPCSA ). Full document checking occurred in 6.842 seconds. Realtime checking while editing occurs in less than 0.01 seconds.
- Update animation demos under Functionality section.
- Added English GB-ize/Oxford dictionary (#75) Thanks kuro68k
- Suggestion severity can be selected from a dropdown (addresses #71)
- Updated Spanish dictionary which contained HTML headers in error
- Add user setting for ignoring file by name (addresses #72)
- Convert icon from svg to png.
- Emit warnings instead of errors. Added new setting to override to error (#62)
- Fixed bug in YAML config extraction (#61)
- Added Swedish language support (#46) Thanks jsve
- Updated to newest vscode extension API
- Bump npm and other package versions
- Updates to README (#52, #53) Thanks PeterJCLaw
- Update Typescript formatting to be more typical
- Fixed bug in migration of old settings files (#41)
- Added settings to package.json so that VSCode doesn't give warnings when editing
- Workspace settings are now included in
.vscode/spellchecker.json will be migrated with the option to delete.
- Removed 'CreateConfigurationFile' action because configuration can now be handled though
File > Preferences > Settings.
- Added command to set language.
- Pandoc YAML front matter can end with
- Added Greek language support (Thanks tsangiotis).
- Added French language support (Thanks adrienjoly).
- Added extension icon.
- Changed spell check actions to 'Ignore' (add to workspace dictionary) and 'Always Ignore' (add to user dictionary).
- Changes to either the user or workspace settings.json will be automatically loaded when changed.
- Fixed #28. The last character of the last suggestion was being cut off.
- Fixed bug introduced by context menu changes when there are no suggested spellings.
- Added Spanish dictionary, es_ANY. Thanks jmalarcon
- Fixed context menu not handling special characters in suggestions (#25)
- Detect Insider version for different user settings file.
- Add svg and pdf to
ignoreRegExp (#16, Thanks wingsuitist)
- Fixed wrong/incomplete comment removal in settings (#20, Thanks devjb)
- Adding extra output to configuration file creation to help track down errors during this process
- Only process files with
uri.scheme = 'file' (See #15)
- Find suggestions for words that do not contain numbers (See #15)
- Added GB English dictionary (#12)
- Fixed some regex's mangling text parsing by replacing spaces instead of null.
- Fixed error with creating settings file to
.vscode folder that doesn't exist.
- Added command to show current
documentType to make it easier to add new types to check.
- Fixed files not being opened when workspace was not opened.
checkInterval setting so that spelling isn't checked with every edit but rather after a specified interval.
- For long files or files with lots of errors, VSCode can freeze because the spell checker takes too long. The error list only shows 250 errors, so checking is stopped after that number has been found. When this happens, a message
"Over 250 spelling errors found!" is displayed in the status bar for 5 seconds.
Add word to dictionary function now saves the word to the workspace's
- User Preferences can now include Spell Checker settings.
Always ignore word option. Settings save in the User Preferences.
~ to the list of characters to ignore before spell checking.
- Removed latex commands from spell checking, e.g.
Create Spell Checker Settings File command.
- Words under 50 characters in length will be checked for suggestions. The longest English word is 45 characters.
- Add setting
ignoreFileExtensions to ignore spell checking on files with certain extensions
- Fixed parsing leading quotation marks didn't work when the marks were in front of a number
- Fixed error with tab characters not being removed from text
- Fixed error in parsing quotation marks at the beginning of words
- More detailed README
- Replaced right single quotation mark (character code 0x2019) when used in contractions
Big thanks to Sean McBreen for Spell and Grammar Check.