blob: 84c9e753b564e8b523e2a13b5a3c6faaff2e4505 [file] [log] [blame]
Bram Moolenaar6bb68362005-03-22 23:03:44 +00001*spell.txt* For Vim version 7.0aa. Last change: 2005 Mar 22
Bram Moolenaar217ad922005-03-20 22:37:15 +00002
3
4 VIM REFERENCE MANUAL by Bram Moolenaar
5
6
7Spell checking *spell*
8
91. Quick start |spell-quickstart|
10X. Spell file format |spell-file-format|
11
12{Vi does not have any of these commands}
13
14Spell checking is not available when the |+syntax| feature has been disabled
15at compile time.
16
17==============================================================================
181. Quick start *spell-quickstart*
19
20This command switches on spell checking: >
21
22 :setlocal spell spelllang=en_us
23
24This switches the 'spell' option on and specifies to check for US English.
25
26The words that are not recognized are highlighted with one of these:
27 SpellBad word not recognized
28 SpellRare rare word
29 SpellLocal wrong spelling for selected region
30
31
Bram Moolenaar6bb68362005-03-22 23:03:44 +000032PERFORMANCE
33
34Note that Vim does on-the-fly spellchecking. To make this work fast the
35word list is loaded in memory. Thus this uses a lot of memory (2 Mbyte or
36more). There might also be a noticable delay when the word list is loaded,
37which happens when 'spelllang' is set. Each word list is only loaded once,
38they are not deleted when 'spelllang' is made empty. When 'encoding' is set
39the word lists are reloaded, thus you may notice a delay then too.
40
41
Bram Moolenaar217ad922005-03-20 22:37:15 +000042REGIONS
43
44A word may be spelled differently in various regions. For example, English
45comes in (at least) these variants:
46
47 en all regions
48 en_us US
49 en_gb Great Britain
50 en_ca Canada
51
52Words that are not used in one region but are used in another region are
53highlighted with SpellLocal.
54
55Always use lowercase letters.
56
57
58SPELL FILES
59
60Vim searches for spell files in the "spell" subdirectory of the directories in
61'runtimepath'. The name is: xx.yyy.spl, where:
62 xx the language name
63 yyy the value of 'encoding'
64
65Exception: Vim uses "latin1" when 'encoding' is "iso-8859-15". The euro sign
66doesn't matter for spelling.
67
Bram Moolenaar6bb68362005-03-22 23:03:44 +000068Spelling for EBCDIC is currently not supported.
69
Bram Moolenaar217ad922005-03-20 22:37:15 +000070A spell file might not be available in the current 'encoding'. You may try
71using the "iconv" program to create one: >
72
73 iconv -f latin1 -t koi8-r de.latin1.spl >de.koi8-r.spl
74
75However, if some characters cannot be presented in the target encoding this
76will give wrong results.
77
78If a spell file only uses ASCII characters the encoding can be omitted. This
79is useful for English: "en.spl" The file with encoding is checked first, thus
80you could have one with encoding that includes words with non-ASCII characters
81and use the ASCII file as a fall-back.
82
Bram Moolenaar6bb68362005-03-22 23:03:44 +000083
84WORDS
85
86Vim uses a fixed method to recognize a word. This is independent of
87'iskeyword', so that it also works in help files and for languages that
88include characters like '-' in 'iskeyword'. The word characters do depend on
89'encoding'.
90
91A word that starts with a digit is always ignored.
92
93
94SYNTAX HIGHLIGHTING
95
96Files that use syntax highlighting can specify where spell checking should be
97done:
98
99 everywhere default
100 in specific items use "contains=@Spell"
101 everywhere but specific items use "contains=@NoSpell"
102
103Note that mixing @Spell and @NoSpell doesn't make sense.
104
Bram Moolenaar217ad922005-03-20 22:37:15 +0000105==============================================================================
106X. Spell file format *spell-file-format*
107 *E751*
108
109The spelling for a language is specified in file with a specific format.
110The first character of a line specifies what follows in the line:
111
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000112 line meaning ~
113 -xx[-yy]... words for region xx (and region yy, etc.) follow
114 <word> normal word
115 ><word> rare word
116 +<word> optional addition after a word
117 !<word> normal word, keep upper/lower case
118 !><word> rare word, keep upper/lower case
119 !+<word> optional word addition, keep upper/lower case
120 #<anything> comment
Bram Moolenaar217ad922005-03-20 22:37:15 +0000121
122Empty lines are ignored. The word continues until the end of the line. Watch
123out for trailing white space!
124
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000125Words that start with an upper-case letter will be required to start with an
126upper-case letter. Otherwise, words must be in lower-case and case is
127ignored.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000128
129It is possible that a word appears both with an upper-case letter and as a
130rare word. This means that the word with an upper-case letter is OK and the
131word without the upper-case letter is rare.
132 *E753*
133The region is specified with "-xx". For example, in the "en.spl" file "-us"
134starts the word for "en_us". This can be repeated for words that are used in
135more than one region. For example "-ca-us" is used for Canadian and US
136English words. Use "---" to go back to the words for all regions.
137
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000138Vim supports up to eight regions. *E752*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000139
140It is possible to have a match that starts with a valid word. In that case
141the match is used, because it is longer. Example:
142
143 we
144 =we're
145
146"re" is not a word, thus "=we're" is needed to avoid it gets highlighted.
147
148The "+" items may appear after any word. For English "'s" is used. Be
149careful with this, it may hide mistakes.
150
151Vim will check for duplicate words in the files used, but you will only get
152warnings if the 'verbose' option is set to 1 or more.
153
154Note that the "=" and "+" words will slow down the operation. Use them only
155when really needed.
156
157
158 vim:tw=78:sw=4:ts=8:ft=help:norl: