The [spellchecker] command.

Introduction

The spellchecker command lets you interact with the OS X spell checking facilities.

Synopsis

The formal syntax of the [spellchecker] command is:
spellchecker subcommand ?options?
The possible subcommands are described below. Depending on the subcommand, some options may be specified.

Spellcheck subcommands

The [automatic] subcommand

This subcommand lets you handle automatic languages identification. The complete syntax is:
    spellchecker automatic ?(0|1)?
If it is used without argument, the command tells whether the spell checker will automatically identify languages. Otherwise, it enables or disables the automatic languages detection.

The [check] subcommand

This subcommand lets you search the next misspelled word. The complete syntax is:
    spellchecker check ?-w win? ?-from pos? ?-language str?
If the -w option is not specified, the command applies to the frontmost document window. The -from option specifies the starting position. By default, the search starts at the end of the current selection.
The -language option specifies the language used for spell checking. By default, this is the language returned by the [spellchecker language] command.
The command raises an error if no misspelled word was found. Otherwise it returns the range of the first misspelled word.

The [guesses] subcommand

This subcommand returns an array of possible substitutions for the specified range or word. The syntax has two forms:
    spellchecker guesses ?-w win? ?-language str? from to
    spellchecker guesses ?-w win? ?-language str? word
In the first form, the from and to arguments specify the range of a misspelled word in the document, typically obtained by the [spellchecker check] command. In the second form, you pass directly a misspelled word.
The -language option specifies the language used for spell checking. By default, this is the language returned by the [spellchecker language] command.
If the -w option is not specified, the command applies to the frontmost document window.
The command returns a list of possible replacement words.

The [ignoredWords] subcommand

This subcommand lets you get or set the list of ignored words for a document. The complete syntax is:
    spellchecker ignoredWords ?-w win? ?list_of_words?
If the -w option is not specified, the command applies to the frontmost document window.
The words are returned in an unpredictable order.

The [language] subcommand

This subcommand lets you get or set the current language used for spell checking. The complete syntax takes two forms:
    spellchecker language ?-iso? 
    spellchecker language ?-iso? lang
The first form of the command returns the current language. If the -iso option is specified, the command returns the ISO 3166-1 code of the language.
The second form of the command is used to set the language. In that case, one may omit the -iso option. The command can guess automatically if lang is a display name or an ISO code.
To learn about the strings you can use to specify a language, see Language and Locale Designations. The available languages can be obtained using the [spellchecker languages] command.

The [languages] subcommand

This subcommand provides a list of all available languages for spell checking. The complete syntax is:
    spellchecker languages ?-iso? ?-user?
If the -user option is specified, the command returns a subset of the available languages corresponding to the user’s preferred languages. Otherwise, the command returns all the available spell checking languages. The languages are ordered in the user’s preferred order as set in the system preferences.
If the -iso option is specified, the command returns the ISO 3166-1 code of the languages (such as en, en_GB, fr, etc.).

The [learn] subcommand

This subcommand lets you add a word to the spell checker dictionary. The complete syntax is:
    spellchecker learn ?-c? word
If the option -c is not specified, the command installs the word word in the user's "learn" list for the current language.
If -c is specified, the command tells whether the word is installed in the user's "learn" list for the current language.
To remove a word from the list, see the [spellchecker unlearn] command.

The [misspelled] subcommand

This subcommand tells whether a word is considered misspelled. The complete syntax is:
    spellchecker misspelled ?-w win? ?-language str? word
The -language option specifies the language used for spell checking. By default, this is the language returned by the [spellchecker language] command.
If the -w option is not specified, the command applies to the frontmost document window. If you want a response that is independent of any document, you can specify an empty value for this option.
The command returns a boolean value.

The [substitutionsPanel] subcommand

This subcommand lets you show or hide the substitutions panel. The complete syntax is:
    spellchecker substitutionsPanel ?(0|1)?
Substitutions are user defined system-wide replacement strings which may be specified in the Text panel of the Keyboard System Preferences panel. If it is used without argument, the command returns 1 or 0 to indicate whether the panel is currently visible or not.
Text substitutions panel

The [unlearn] subcommand

This subcommand lets you tell the spell checker to unlearn a given word. The complete syntax is:
    spellchecker unlearn word
The command removes the word word from the user's "learn" list for the current language.

Examples

Get or set the language:
«» spellchecker language
en
«» spellchecker language fr
«» spellchecker language en_GB
«» spellchecker language English
«» spellchecker language German
«» spellchecker language
de
Check the spelling of the current document:
«» spellchecker check -from 0
Get or set the list of ignored words for the current document:
«» spellchecker ignoredWords [list foo bar baz]
«» spellchecker ignoredWords 
bar baz foo


Last updated 2020-05-27 14:28:48