301
|
1 *spell.txt* For Vim version 7.0aa. Last change: 2005 Jun 04
|
221
|
2
|
|
3
|
|
4 VIM REFERENCE MANUAL by Bram Moolenaar
|
|
5
|
|
6
|
|
7 Spell checking *spell*
|
|
8
|
|
9 1. Quick start |spell-quickstart|
|
237
|
10 2. Generating a spell file |spell-mkspell|
|
|
11 9. Spell file format |spell-file-format|
|
221
|
12
|
|
13 {Vi does not have any of these commands}
|
|
14
|
|
15 Spell checking is not available when the |+syntax| feature has been disabled
|
|
16 at compile time.
|
|
17
|
|
18 ==============================================================================
|
|
19 1. Quick start *spell-quickstart*
|
|
20
|
|
21 This command switches on spell checking: >
|
|
22
|
|
23 :setlocal spell spelllang=en_us
|
|
24
|
237
|
25 This switches on the 'spell' option and specifies to check for US English.
|
221
|
26
|
|
27 The words that are not recognized are highlighted with one of these:
|
|
28 SpellBad word not recognized
|
|
29 SpellRare rare word
|
|
30 SpellLocal wrong spelling for selected region
|
|
31
|
237
|
32 Vim only checks words for spelling, there is no grammar check.
|
|
33
|
|
34 To search for the next misspelled word:
|
|
35
|
|
36 *]s* *E756*
|
|
37 ]s Move to next misspelled word after the cursor.
|
253
|
38 A count before the command can be used to repeat.
|
|
39 This uses the @Spell and @NoSpell clusters from syntax
|
|
40 highlighting, see |spell-syntax|.
|
237
|
41
|
|
42 *[s*
|
253
|
43 [s Like "]s" but search backwards, find the misspelled
|
|
44 word before the cursor.
|
|
45
|
|
46 *]S*
|
|
47 ]S Like "]s" but only stop at bad words, not at rare
|
|
48 words or words for another region.
|
|
49
|
|
50 *[S*
|
|
51 [S Like "]S" but search backwards.
|
237
|
52
|
221
|
53
|
227
|
54 PERFORMANCE
|
|
55
|
|
56 Note that Vim does on-the-fly spellchecking. To make this work fast the
|
237
|
57 word list is loaded in memory. Thus this uses a lot of memory (1 Mbyte or
|
227
|
58 more). There might also be a noticable delay when the word list is loaded,
|
|
59 which happens when 'spelllang' is set. Each word list is only loaded once,
|
|
60 they are not deleted when 'spelllang' is made empty. When 'encoding' is set
|
|
61 the word lists are reloaded, thus you may notice a delay then too.
|
|
62
|
|
63
|
221
|
64 REGIONS
|
|
65
|
|
66 A word may be spelled differently in various regions. For example, English
|
|
67 comes in (at least) these variants:
|
|
68
|
|
69 en all regions
|
247
|
70 en_au Australia
|
|
71 en_ca Canada
|
221
|
72 en_gb Great Britain
|
247
|
73 en_nz New Zealand
|
|
74 en_us USA
|
221
|
75
|
|
76 Words that are not used in one region but are used in another region are
|
|
77 highlighted with SpellLocal.
|
|
78
|
237
|
79 Always use lowercase letters for the language and region names.
|
221
|
80
|
|
81
|
|
82 SPELL FILES
|
|
83
|
|
84 Vim searches for spell files in the "spell" subdirectory of the directories in
|
237
|
85 'runtimepath'. The name is: LL-XXX.EEE.spl, where:
|
|
86 LL the language name
|
|
87 -XXX optional addition
|
|
88 EEE the value of 'encoding'
|
221
|
89
|
242
|
90 Exceptions:
|
|
91 - Vim uses "latin1" when 'encoding' is "iso-8859-15". The euro sign doesn't
|
|
92 matter for spelling.
|
|
93 - When no spell file for 'encoding' is found "ascii" is tried. This only
|
|
94 works for languages where nearly all words are ASCII, such as English. It
|
|
95 helps when 'encoding' is not "latin1", such as iso-8859-2, and English text
|
|
96 is being edited.
|
221
|
97
|
227
|
98 Spelling for EBCDIC is currently not supported.
|
|
99
|
237
|
100 A spell file might not be available in the current 'encoding'. See
|
|
101 |spell-mkspell| about how to create a spell file. Converting a spell file
|
242
|
102 with "iconv" will NOT work!
|
221
|
103
|
237
|
104 *E758* *E759*
|
|
105 When loading a spell file Vim checks that it is properly formatted. If you
|
242
|
106 get an error the file may be truncated, modified or intended for another Vim
|
|
107 version.
|
237
|
108
|
227
|
109
|
|
110 WORDS
|
|
111
|
|
112 Vim uses a fixed method to recognize a word. This is independent of
|
|
113 'iskeyword', so that it also works in help files and for languages that
|
|
114 include characters like '-' in 'iskeyword'. The word characters do depend on
|
|
115 'encoding'.
|
|
116
|
|
117 A word that starts with a digit is always ignored.
|
|
118
|
|
119
|
253
|
120 SYNTAX HIGHLIGHTING *spell-syntax*
|
227
|
121
|
|
122 Files that use syntax highlighting can specify where spell checking should be
|
|
123 done:
|
|
124
|
|
125 everywhere default
|
|
126 in specific items use "contains=@Spell"
|
|
127 everywhere but specific items use "contains=@NoSpell"
|
|
128
|
|
129 Note that mixing @Spell and @NoSpell doesn't make sense.
|
|
130
|
221
|
131 ==============================================================================
|
237
|
132 2. Generating a spell file *spell-mkspell*
|
|
133
|
|
134 Vim uses a binary file format for spelling. This greatly speeds up loading
|
|
135 the word list and keeps it small.
|
|
136
|
|
137 You can create a Vim spell file from the .aff and .dic files that Myspell
|
|
138 uses. Myspell is used by OpenOffice.org and Mozilla. You should be able to
|
|
139 find them here:
|
|
140 http://lingucomponent.openoffice.org/spell_dic.html
|
221
|
141
|
242
|
142 :mksp[ell] [-ascii] {outname} {inname} ... *:mksp* *:mkspell*
|
301
|
143 Generate spell file {outname}.spl.
|
|
144
|
242
|
145 When the [-ascii] argument is present, words with
|
|
146 non-ascii characters are skipped. The resulting file
|
|
147 ends in "ascii.spl". Otherwise the resulting file
|
|
148 ends in "ENC.spl", where ENC is the value of
|
|
149 'encoding'.
|
301
|
150
|
|
151 The input can be the Myspell format files {inname}.aff
|
|
152 and {inname}.dic. If {inname}.aff does not exist then
|
|
153 {inname} is used as the file name of a plain word
|
|
154 list.
|
|
155
|
237
|
156 Multiple {inname} arguments can be given to combine
|
|
157 regions into one Vim spell file. Example: >
|
|
158 :mkspell ~/.vim/spell/en /tmp/en_US /tmp/en_CA /tmp/en_AU
|
|
159 < This combines the English word lists for US, CA and AU
|
|
160 into one en.spl file.
|
|
161 Up to eight regions can be combined. *E754* *755*
|
|
162
|
|
163 Since you might want to change the word list for use with Vim the following
|
|
164 procedure is recommended:
|
|
165
|
|
166 1. Obtain the xx_YY.aff and xx_YY.dic files from Myspell.
|
|
167 2. Make a copy of these files to xx_YY.orig.aff and xx_YY.orig.dic.
|
|
168 3. Change the xx_YY.aff and xx_YY.dic files to remove bad words, add missing
|
258
|
169 words, define word characters with FOL/LOW/UPP, etc. The distributed
|
|
170 "src/spell/*.diff" files can be used.
|
|
171 4. Set 'encoding' to the desired encoding and use |:mkspell| to generate the
|
|
172 Vim spell file.
|
|
173 5. Try out the spell file with ":set spell spelllang=xx_YY".
|
221
|
174
|
237
|
175 When the Myspell files are updated you can merge the differences:
|
258
|
176 1. Obtain the new Myspell files as xx_YY.new.aff and xx_UU.new.dic.
|
|
177 2. Use Vimdiff to see what changed: >
|
237
|
178 vimdiff xx_YY.orig.dic xx_YY.new.dic
|
258
|
179 3. Take over the changes you like in xx_YY.dic.
|
237
|
180 You may also need to change xx_YY.aff.
|
258
|
181 4. Rename xx_YY.new.dic to xx_YY.orig.dic and xx_YY.new.aff to xx_YY.new.aff.
|
237
|
182
|
|
183 ==============================================================================
|
|
184 9. Spell file format *spell-file-format*
|
|
185
|
|
186 This is the format of the files that are used by the person who creates and
|
|
187 maintains a word list.
|
221
|
188
|
237
|
189 Note that we avoid the word "dictionary" here. That is because the goal of
|
|
190 spell checking differs from writing a dictionary (as in the book). For
|
|
191 spelling we need a list of words that are OK, thus need not to be highlighted.
|
|
192 Names will not appear in a dictionary, but do appear in a word list. And
|
|
193 some old words are rarely used and are common misspellings. These do appear
|
|
194 in a dictionary but not in a word list.
|
|
195
|
301
|
196 There are two formats: one with affix compression and one without. The files
|
|
197 with affix compression are used by Myspell (Mozilla and OpenOffice.org). This
|
|
198 requires two files, one with .aff and one with .dic extension. The second
|
|
199 format is a list of words.
|
|
200
|
|
201
|
|
202 FORMAT OF WORD LIST
|
|
203
|
|
204 The words must appear one per line. That is all that is required. Optional
|
|
205 items are:
|
|
206 - Empty and blank lines are ignored.
|
|
207 - Lines starting with a # are ignored (comment lines).
|
|
208 - A line starting with "=encoding=" before any word. After the second '='
|
|
209 comes an encoding name. This tells Vim to setup conversion from the
|
|
210 specified encoding to 'encoding'.
|
|
211 - Other lines starting with '=' are special. The ones that are not recognized
|
|
212 are ignored (but you do get a warning message).
|
|
213
|
|
214
|
|
215 FORMAT WITH AFFIX COMPRESSION
|
|
216
|
237
|
217 There are two files: the basic word list and an affix file. The affixes are
|
|
218 used to modify the basic words to get the full word list. This significantly
|
|
219 reduces the number of words, especially for a language like Polish. This is
|
|
220 called affix compression.
|
221
|
221
|
237
|
222 The format for the affix and word list files is mostly identical to what
|
|
223 Myspell uses (the spell checker of Mozilla and OpenOffice.org). A description
|
|
224 can be found here:
|
|
225 http://lingucomponent.openoffice.org/affix.readme ~
|
|
226 Note that affixes are case sensitive, this isn't obvious from the description.
|
|
227 Vim supports a few extras. Hopefully Myspell will support these too some day.
|
|
228 See |spell-affix-vim|.
|
|
229
|
|
230 The basic word list and the affix file are combined and turned into a binary
|
|
231 spell file. All the preprocessing has been done, thus this file loads fast.
|
|
232 The binary spell file format is described in the source code (src/spell.c).
|
|
233 But only developers need to know about it.
|
221
|
234
|
237
|
235 The preprocessing also allows us to take the Myspell language files and modify
|
|
236 them before the Vim word list is made. The tools for this can be found in the
|
|
237 "src/spell" directory.
|
|
238
|
|
239
|
|
240 WORD LIST FORMAT *spell-wordlist-format*
|
|
241
|
|
242 A very short example, with line numbers:
|
221
|
243
|
237
|
244 1 1234
|
|
245 2 aan
|
|
246 3 Als
|
|
247 4 Etten-Leur
|
|
248 5 et al.
|
|
249 6 's-Gravenhage
|
|
250 7 's-Gravenhaags
|
|
251 8 bedel/P
|
|
252 9 kado/1
|
|
253 10 cadeau/2
|
|
254
|
|
255 The first line contains the number of words. Vim ignores it. *E760*
|
221
|
256
|
237
|
257 What follows is one word per line. There should be no white space after the
|
|
258 word.
|
|
259
|
|
260 When the word only has lower-case letters it will also match with the word
|
|
261 starting with an upper-case letter.
|
|
262
|
|
263 When the word includes an upper-case letter, this means the upper-case letter
|
|
264 is required at this position. The same word with a lower-case letter at this
|
|
265 position will not match. When some of the other letters are upper-case it will
|
|
266 not match either.
|
|
267
|
|
268 The same word with all upper-case characters will always be OK.
|
221
|
269
|
237
|
270 word list matches does not match ~
|
|
271 als als Als ALS ALs AlS aLs aLS
|
|
272 Als Als ALS als ALs AlS aLs aLS
|
|
273 ALS ALS als Als ALs AlS aLs aLS
|
|
274 AlS AlS ALS als Als ALs aLs aLS
|
221
|
275
|
237
|
276 Note in line 5 to 7 that non-word characters are used. You can include
|
|
277 any character in a word. When checking the text a word still only matches
|
|
278 when it appears with a non-word character before and after it. For Myspell a
|
|
279 word starting with a non-word character probably won't work.
|
|
280
|
|
281 After the word there is an optional slash and flags. Most of these flags are
|
|
282 letters that indicate the affixes that can be used with this word.
|
221
|
283
|
237
|
284 *spell-affix-vim*
|
|
285 A flag that Vim adds and is not in Myspell is the "=" flag. This has the
|
|
286 meaning that case matters. This can be used if the word does not have the
|
|
287 first letter in upper case at the start of a sentence. Example:
|
|
288
|
|
289 word list matches does not match ~
|
|
290 's morgens/= 's morgens 'S morgens 's Morgens
|
|
291 's Morgens 's Morgens 'S morgens 's morgens
|
221
|
292
|
237
|
293 *spell-affix-mbyte*
|
|
294 The basic word list is normally in an 8-bit encoding, which is mentioned in
|
|
295 the affix file. The affix file must always be in the same encoding as the
|
|
296 word list. This is compatible with Myspell. For Vim the encoding may also be
|
|
297 something else, any encoding that "iconv" supports. The "SET" line must
|
|
298 specify the name of the encoding. When using a multi-byte encoding it's
|
|
299 possible to use more different affixes.
|
221
|
300
|
237
|
301 Performance hint: Although using affixes reduces the number of words, it
|
|
302 reduces the speed. It's a good idea to put all the often used words in the
|
|
303 word list with the affixes prepended/appended.
|
221
|
304
|
258
|
305 *spell-affix-chars*
|
|
306 The affix file should define the word characters when using an 8-bit encoding
|
|
307 (as specified with ENC). This is because the system where ":mkspell" is used
|
|
308 may not support a locale with this encoding and isalpha() won't work. For
|
|
309 example when using "cp1250" on Unix.
|
|
310
|
|
311 *E761* *E762*
|
|
312 Three lines in the affix file are needed. Simplistic example:
|
|
313
|
|
314 FOL áëñáëñ
|
|
315 LOW áëñáëñ
|
|
316 UPP áëñÁËÑ
|
|
317
|
|
318 All three lines must have exactly the same number of characters.
|
|
319
|
|
320 The "FOL" line specifies the case-folded characters. These are used to
|
|
321 compare words while ignoring case. For most encodings this is identical to
|
|
322 the lower case line.
|
|
323
|
|
324 The "LOW" line specifies the characters in lower-case. Mostly it's equal to
|
|
325 the "FOL" line.
|
|
326
|
|
327 The "UPP" line specifies the characters with upper-case. That is, a character
|
|
328 is upper-case where it's different from the character at the same position in
|
|
329 "FOL".
|
|
330
|
|
331 ASCII characters should be omitted, Vim always handles these in the same way.
|
|
332 When the encoding is UTF-8 no word characters need to be specified.
|
|
333
|
|
334 *E763*
|
|
335 All spell files for the same encoding must use the same word characters,
|
264
|
336 otherwise they can't be combined without errors. The XX.ascii.spl spell file
|
|
337 generated with the "-ascii" argument will not contain the table with
|
|
338 characters, so that it can be combine with spell files for any encoding.
|
258
|
339
|
221
|
340
|
|
341 vim:tw=78:sw=4:ts=8:ft=help:norl:
|