374
|
1 *spell.txt* For Vim version 7.0aa. Last change: 2005 Jun 28
|
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|
|
314
|
11 3. 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:
|
333
|
28 SpellBad word not recognized |hl-SpellBad|
|
|
29 SpellRare rare word |hl-SpellRare|
|
|
30 SpellLocal wrong spelling for selected region |hl-SpellLocal|
|
221
|
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
|
348
|
44 word before the cursor. Doesn't recognize words
|
|
45 split over two lines, thus may stop at words that are
|
|
46 not highlighted as bad.
|
253
|
47
|
|
48 *]S*
|
|
49 ]S Like "]s" but only stop at bad words, not at rare
|
|
50 words or words for another region.
|
|
51
|
|
52 *[S*
|
|
53 [S Like "]S" but search backwards.
|
237
|
54
|
221
|
55
|
323
|
56 To add words to your own word list: *E764*
|
314
|
57
|
|
58 *zg*
|
|
59 zg Add word under the cursor as a good word to
|
|
60 'spellfile'. In Visual mode the selected characters
|
|
61 are added as a word (including white space!).
|
|
62
|
|
63 *zw*
|
|
64 zw Add word under the cursor as a wrong (bad) word to
|
|
65 'spellfile'. In Visual mode the selected characters
|
|
66 are added as a word (including white space!).
|
|
67
|
333
|
68 *:spe* *:spellgood*
|
|
69 :spe[llgood] {word} Add [word} as a good word to 'spellfile'.
|
314
|
70
|
333
|
71 *:spellw* *:spellwrong*
|
314
|
72 :spellw[rong] {word} Add [word} as a wrong (bad) word to 'spellfile'.
|
|
73
|
359
|
74 After adding a word to 'spellfile' with the above commands its associated
|
|
75 ".spl" file will automatically be updated. If you edit 'spellfile' manually
|
|
76 you need to use the |:mkspell| command. This sequence of commands mostly
|
|
77 works well: >
|
|
78 :exe 'e ' . &spellfile
|
|
79 < (make changes to the spell file) >
|
|
80 :mkspell! %
|
|
81
|
|
82 More details about the 'spellfile' format below |spell-wordlist-format|.
|
314
|
83
|
|
84
|
323
|
85 Finding suggestions for bad words:
|
|
86
|
|
87 *z?*
|
348
|
88 z? For the word under/after the cursor suggest correctly
|
|
89 spelled words. This also works to find alternative
|
374
|
90 for words that are not highlighted as bad words, e.g.,
|
|
91 when the word after it is bad.
|
348
|
92 The results are sorted on similarity to the word
|
|
93 under/after the cursor.
|
323
|
94 This may take a long time. Hit CTRL-C when you are
|
|
95 bored.
|
374
|
96 This does not work when there is a line break halfway
|
|
97 a bad word (e.g., "the the").
|
323
|
98 You can enter the number of your choice or press
|
374
|
99 <Enter> if you don't want to replace. You can also
|
|
100 use the mouse to click on your choice (only works if
|
|
101 the mouse can be used in Normal mode and when there
|
|
102 are no line wraps!). Click on the first (header) line
|
|
103 to cancel.
|
327
|
104 If 'verbose' is non-zero a score will be displayed to
|
|
105 indicate the likeliness to the badly spelled word (the
|
|
106 higher the score the more different).
|
344
|
107 When a word was replaced the redo command "." will
|
|
108 repeat the word replacement. This works like "ciw",
|
|
109 the good word and <Esc>.
|
|
110
|
374
|
111 *:spellr* *:spellrepall* *E752* *E753*
|
|
112 :spellr[epall] Repeat the replacement done by |z?| for all matches
|
|
113 with the replaced word in the current window.
|
|
114
|
344
|
115 The 'spellsuggest' option influences how the list of suggestions is generated
|
|
116 and sorted. See |'spellsuggest'|.
|
323
|
117
|
|
118
|
227
|
119 PERFORMANCE
|
|
120
|
374
|
121 Note that Vim does on-the-fly spell checking. To make this work fast the word
|
|
122 list is loaded in memory. Thus this uses a lot of memory (1 Mbyte or more).
|
|
123 There might also be a noticeable delay when the word list is loaded, which
|
|
124 happens when 'spell' is set and when 'spelllang' is set while 'spell' was
|
|
125 already set. To minimize the delay each word list is only loaded once, it
|
|
126 is not deleted when 'spelllang' is made empty or 'spell' is reset. When
|
|
127 'encoding' is set all the word lists are reloaded, thus you may notice a delay
|
|
128 then too.
|
227
|
129
|
|
130
|
221
|
131 REGIONS
|
|
132
|
|
133 A word may be spelled differently in various regions. For example, English
|
|
134 comes in (at least) these variants:
|
|
135
|
|
136 en all regions
|
247
|
137 en_au Australia
|
|
138 en_ca Canada
|
221
|
139 en_gb Great Britain
|
247
|
140 en_nz New Zealand
|
|
141 en_us USA
|
221
|
142
|
|
143 Words that are not used in one region but are used in another region are
|
333
|
144 highlighted with SpellLocal |hl-SpellLocal|.
|
221
|
145
|
237
|
146 Always use lowercase letters for the language and region names.
|
221
|
147
|
320
|
148 When adding a word with |zg| or another command it's always added for all
|
|
149 regions. You can change that by manually editing the 'spellfile'. See
|
|
150 |spell-wordlist-format|.
|
|
151
|
221
|
152
|
353
|
153 SPELL FILES *spell-load*
|
221
|
154
|
|
155 Vim searches for spell files in the "spell" subdirectory of the directories in
|
320
|
156 'runtimepath'. The name is: LL.EEE.spl, where:
|
237
|
157 LL the language name
|
|
158 EEE the value of 'encoding'
|
221
|
159
|
353
|
160 The value for "LL" comes from 'spelllang', but excludes the region name.
|
|
161 Examples:
|
|
162 'spelllang' LL ~
|
|
163 en_us en
|
|
164 en-rare en-rare
|
|
165 medical_ca medical
|
|
166
|
320
|
167 Only the first file is loaded, the one that is first in 'runtimepath'. If
|
|
168 this succeeds then additionally files with the name LL.EEE.add.spl are loaded.
|
|
169 All the ones that are found are used.
|
|
170
|
353
|
171 Additionally, the file related to 'spellfile' is loaded. This is the file
|
|
172 that |zg| and |zw| add good and wrong words to.
|
|
173
|
242
|
174 Exceptions:
|
|
175 - Vim uses "latin1" when 'encoding' is "iso-8859-15". The euro sign doesn't
|
|
176 matter for spelling.
|
|
177 - When no spell file for 'encoding' is found "ascii" is tried. This only
|
|
178 works for languages where nearly all words are ASCII, such as English. It
|
|
179 helps when 'encoding' is not "latin1", such as iso-8859-2, and English text
|
320
|
180 is being edited. For the ".add" files the same name as the found main
|
|
181 spell file is used.
|
|
182
|
|
183 For example, with these values:
|
|
184 'runtimepath' is "~/.vim,/usr/share/vim70,~/.vim/after"
|
|
185 'encoding' is "iso-8859-2"
|
|
186 'spelllang' is "pl"
|
|
187
|
|
188 Vim will look for:
|
|
189 1. ~/.vim/spell/pl.iso-8859-2.spl
|
|
190 2. /usr/share/vim70/spell/pl.iso-8859-2.spl
|
|
191 3. ~/.vim/spell/pl.iso-8859-2.add.spl
|
|
192 4. /usr/share/vim70/spell/pl.iso-8859-2.add.spl
|
|
193 5. ~/.vim/after/spell/pl.iso-8859-2.add.spl
|
|
194
|
|
195 This assumes 1. is not found and 2. is found.
|
|
196
|
|
197 If 'encoding' is "latin1" Vim will look for:
|
|
198 1. ~/.vim/spell/pl.latin1.spl
|
|
199 2. /usr/share/vim70/spell/pl.latin1.spl
|
|
200 3. ~/.vim/after/spell/pl.latin1.spl
|
|
201 4. ~/.vim/spell/pl.ascii.spl
|
|
202 5. /usr/share/vim70/spell/pl.ascii.spl
|
|
203 6. ~/.vim/after/spell/pl.ascii.spl
|
|
204
|
|
205 This assumes none of them are found (Polish doesn't make sense when leaving
|
|
206 out the non-ASCII characters).
|
221
|
207
|
227
|
208 Spelling for EBCDIC is currently not supported.
|
|
209
|
237
|
210 A spell file might not be available in the current 'encoding'. See
|
|
211 |spell-mkspell| about how to create a spell file. Converting a spell file
|
242
|
212 with "iconv" will NOT work!
|
221
|
213
|
237
|
214 *E758* *E759*
|
|
215 When loading a spell file Vim checks that it is properly formatted. If you
|
242
|
216 get an error the file may be truncated, modified or intended for another Vim
|
|
217 version.
|
237
|
218
|
227
|
219
|
|
220 WORDS
|
|
221
|
|
222 Vim uses a fixed method to recognize a word. This is independent of
|
|
223 'iskeyword', so that it also works in help files and for languages that
|
|
224 include characters like '-' in 'iskeyword'. The word characters do depend on
|
|
225 'encoding'.
|
|
226
|
323
|
227 The table with word characters is stored in the main .spl file. Therefore it
|
|
228 matters what the current locale is when generating it! A .add.spl file does
|
359
|
229 not contain a word table though.
|
323
|
230
|
320
|
231 A word that starts with a digit is always ignored. That includes hex numbers
|
|
232 in the form 0xff and 0XFF.
|
227
|
233
|
|
234
|
348
|
235 WORD COMBINATIONS
|
|
236
|
|
237 It is possible to spell-check words that include a space. This is used to
|
|
238 recognize words that are invalid when used by themselves, e.g. for "et al.".
|
|
239 It can also be used to recognize "the the" and highlight it.
|
|
240
|
|
241 The number of spaces is irrelevant. In most cases a line break may also
|
|
242 appear. However, this makes it difficult to find out where to start checking
|
|
243 for spelling mistakes. When you make a change to one line and only that line
|
|
244 is redrawn Vim won't look in the previous line, thus when "et" is at the end
|
|
245 of the previous line "al." will be flagged as an error. And when you type
|
|
246 "the<CR>the" the highlighting doesn't appear until the first line is redrawn.
|
|
247 Use |CTRL-L| to redraw right away. "[s" will also stop at a word combination
|
|
248 with a line break.
|
|
249
|
|
250 When encountering a line break Vim skips characters such as '*', '>' and '"',
|
|
251 so that comments in C, shell and Vim code can be spell checked.
|
|
252
|
|
253
|
253
|
254 SYNTAX HIGHLIGHTING *spell-syntax*
|
227
|
255
|
|
256 Files that use syntax highlighting can specify where spell checking should be
|
|
257 done:
|
|
258
|
320
|
259 1. everywhere default
|
|
260 2. in specific items use "contains=@Spell"
|
|
261 3. everywhere but specific items use "contains=@NoSpell"
|
227
|
262
|
320
|
263 For the second method adding the @NoSpell cluster will disable spell checking
|
|
264 again. This can be used, for example, to add @Spell to the comments of a
|
|
265 program, and add @NoSpell for items that shouldn't be checked.
|
227
|
266
|
348
|
267
|
|
268 VIM SCRIPTS
|
|
269
|
|
270 If you want to write a Vim script that does something with spelling, you may
|
|
271 find these functions useful:
|
|
272
|
|
273 spellbadword() find badly spelled word at the cursor
|
|
274 spellsuggest() get list of spelling suggestions
|
|
275
|
221
|
276 ==============================================================================
|
237
|
277 2. Generating a spell file *spell-mkspell*
|
|
278
|
|
279 Vim uses a binary file format for spelling. This greatly speeds up loading
|
|
280 the word list and keeps it small.
|
371
|
281 *.aff* *.dic* *Myspell*
|
237
|
282 You can create a Vim spell file from the .aff and .dic files that Myspell
|
|
283 uses. Myspell is used by OpenOffice.org and Mozilla. You should be able to
|
|
284 find them here:
|
|
285 http://lingucomponent.openoffice.org/spell_dic.html
|
348
|
286 You can also use a plain word list. The results are the same, the choice
|
|
287 depends on what you find.
|
221
|
288
|
341
|
289 Make sure your current locale is set properly, otherwise Vim doesn't know what
|
|
290 characters are upper/lower case letters. If the locale isn't available (e.g.,
|
|
291 when using an MS-Windows codepage on Unix) add tables to the .aff file
|
353
|
292 |spell-affix-chars|. If the .aff file doesn't define a table then the word
|
|
293 table of the currently active spelling is used. If spelling is not active
|
|
294 then Vim will try to guess.
|
341
|
295
|
353
|
296 *:mksp* *:mkspell*
|
|
297 :mksp[ell][!] [-ascii] {outname} {inname} ...
|
314
|
298 Generate a Vim spell file word lists. Example: >
|
|
299 :mkspell nl nl_NL.words
|
353
|
300 < *E751*
|
314
|
301 When {outname} ends in ".spl" it is used as the output
|
|
302 file name. Otherwise it should be a language name,
|
353
|
303 such as "en", without the region name. The file
|
|
304 written will be "{outname}.{encoding}.spl", where
|
|
305 {encoding} is the value of the 'encoding' option.
|
301
|
306
|
333
|
307 When the output file already exists [!] must be added
|
|
308 to overwrite it.
|
|
309
|
242
|
310 When the [-ascii] argument is present, words with
|
|
311 non-ascii characters are skipped. The resulting file
|
314
|
312 ends in "ascii.spl".
|
301
|
313
|
|
314 The input can be the Myspell format files {inname}.aff
|
|
315 and {inname}.dic. If {inname}.aff does not exist then
|
|
316 {inname} is used as the file name of a plain word
|
|
317 list.
|
|
318
|
237
|
319 Multiple {inname} arguments can be given to combine
|
|
320 regions into one Vim spell file. Example: >
|
|
321 :mkspell ~/.vim/spell/en /tmp/en_US /tmp/en_CA /tmp/en_AU
|
|
322 < This combines the English word lists for US, CA and AU
|
|
323 into one en.spl file.
|
|
324 Up to eight regions can be combined. *E754* *755*
|
323
|
325 The REP and SAL items of the first .aff file where
|
|
326 they appear are used. |spell-affix-REP|
|
|
327 |spell-affix-SAL|
|
237
|
328
|
348
|
329 This command uses a lot of memory, required to find
|
|
330 the optimal word tree (Polish requires a few hundred
|
|
331 Mbyte). The final result will be much smaller.
|
|
332
|
308
|
333 When the spell file was written all currently used
|
|
334 spell files will be reloaded.
|
|
335
|
371
|
336 :mksp[ell] [-ascii] {name}.{enc}.add
|
|
337 Like ":mkspell" above, using {name}.{enc}.add as the
|
|
338 input file and producing an output file that has
|
|
339 ".spl" appended.
|
|
340
|
|
341 :mksp[ell] [-ascii] {name}
|
|
342 Like ":mkspell" above, using {name} as the input file
|
|
343 and producing an output file that has ".{enc}.spl"
|
314
|
344 appended.
|
|
345
|
|
346 Since you might want to change a Myspell word list for use with Vim the
|
|
347 following procedure is recommended:
|
237
|
348
|
|
349 1. Obtain the xx_YY.aff and xx_YY.dic files from Myspell.
|
|
350 2. Make a copy of these files to xx_YY.orig.aff and xx_YY.orig.dic.
|
|
351 3. Change the xx_YY.aff and xx_YY.dic files to remove bad words, add missing
|
258
|
352 words, define word characters with FOL/LOW/UPP, etc. The distributed
|
|
353 "src/spell/*.diff" files can be used.
|
|
354 4. Set 'encoding' to the desired encoding and use |:mkspell| to generate the
|
|
355 Vim spell file.
|
|
356 5. Try out the spell file with ":set spell spelllang=xx_YY".
|
221
|
357
|
237
|
358 When the Myspell files are updated you can merge the differences:
|
258
|
359 1. Obtain the new Myspell files as xx_YY.new.aff and xx_UU.new.dic.
|
|
360 2. Use Vimdiff to see what changed: >
|
237
|
361 vimdiff xx_YY.orig.dic xx_YY.new.dic
|
258
|
362 3. Take over the changes you like in xx_YY.dic.
|
237
|
363 You may also need to change xx_YY.aff.
|
258
|
364 4. Rename xx_YY.new.dic to xx_YY.orig.dic and xx_YY.new.aff to xx_YY.new.aff.
|
237
|
365
|
353
|
366
|
|
367 SPELL FILE DUMP
|
|
368
|
|
369 If for some reason you want to check what words are supported by the currently
|
|
370 used spelling files, use this command:
|
|
371
|
|
372 *:spelldump* *:spelld*
|
|
373 :spelld[ump] Open a new window and fill it with all currently valid
|
|
374 words.
|
|
375 Note: For some languages the result may be huge and
|
|
376 Vim may run out of memory.
|
|
377
|
|
378 The format of the word list is used |spell-wordlist-format|. You should be
|
|
379 able to read it with ":mkspell" to generate one .spl file that includes all
|
|
380 the words.
|
|
381
|
|
382 Only words for the current region are included. No "/regions" line is
|
|
383 generated.
|
|
384
|
|
385 Comment lines are used to indicate which .spl file the words came from.
|
|
386
|
237
|
387 ==============================================================================
|
353
|
388 3. Spell file format *spell-file-format*
|
237
|
389
|
|
390 This is the format of the files that are used by the person who creates and
|
|
391 maintains a word list.
|
221
|
392
|
237
|
393 Note that we avoid the word "dictionary" here. That is because the goal of
|
|
394 spell checking differs from writing a dictionary (as in the book). For
|
|
395 spelling we need a list of words that are OK, thus need not to be highlighted.
|
|
396 Names will not appear in a dictionary, but do appear in a word list. And
|
|
397 some old words are rarely used and are common misspellings. These do appear
|
|
398 in a dictionary but not in a word list.
|
|
399
|
301
|
400 There are two formats: one with affix compression and one without. The files
|
|
401 with affix compression are used by Myspell (Mozilla and OpenOffice.org). This
|
|
402 requires two files, one with .aff and one with .dic extension. The second
|
|
403 format is a list of words.
|
|
404
|
|
405
|
320
|
406 FORMAT OF WORD LIST *spell-wordlist-format*
|
301
|
407
|
314
|
408 The words must appear one per line. That is all that is required.
|
|
409 Additionally the following items are recognized:
|
301
|
410 - Empty and blank lines are ignored.
|
|
411 - Lines starting with a # are ignored (comment lines).
|
308
|
412 - A line starting with "/encoding=", before any word, specifies the encoding
|
|
413 of the file. After the second '=' comes an encoding name. This tells Vim
|
|
414 to setup conversion from the specified encoding to 'encoding'.
|
320
|
415 - A line starting with "/regions=" specifies the region names that are
|
|
416 supported. Each region name must be two ASCII letters. The first one is
|
|
417 region 1. Thus "/regions=usca" has region 1 "us" and region 2 "ca".
|
|
418 In an addition word list the list should be equal to the main word list!
|
308
|
419 - A line starting with "/?" specifies a word that should be marked as rare.
|
|
420 - A line starting with "/!" specifies a word that should be marked as bad.
|
|
421 - A line starting with "/=" specifies a word where case must match exactly.
|
|
422 A "?" or "!" may be following: "/=?" and "/=!".
|
320
|
423 - Digits after "/" indicate the regions in which the word is valid. If no
|
|
424 regions are specified the word is valid in all regions.
|
314
|
425 - Other lines starting with '/' are reserved for future use. The ones that
|
|
426 are not recognized are ignored (but you do get a warning message).
|
301
|
427
|
320
|
428 Example:
|
|
429
|
|
430 # This is an example word list comment
|
|
431 /encoding=latin1 encoding of the file
|
|
432 /regions=uscagb regions "us", "ca" and "gb"
|
|
433 example word for all regions
|
|
434 /1blah word for region 1 "us"
|
344
|
435 /!vim bad word
|
320
|
436 /?3Campbell rare word in region 3 "gb"
|
|
437 /='s mornings keep-case word
|
|
438
|
301
|
439
|
|
440 FORMAT WITH AFFIX COMPRESSION
|
|
441
|
237
|
442 There are two files: the basic word list and an affix file. The affixes are
|
|
443 used to modify the basic words to get the full word list. This significantly
|
|
444 reduces the number of words, especially for a language like Polish. This is
|
|
445 called affix compression.
|
221
|
446
|
237
|
447 The format for the affix and word list files is mostly identical to what
|
|
448 Myspell uses (the spell checker of Mozilla and OpenOffice.org). A description
|
|
449 can be found here:
|
|
450 http://lingucomponent.openoffice.org/affix.readme ~
|
|
451 Note that affixes are case sensitive, this isn't obvious from the description.
|
314
|
452
|
237
|
453 Vim supports a few extras. Hopefully Myspell will support these too some day.
|
|
454 See |spell-affix-vim|.
|
|
455
|
|
456 The basic word list and the affix file are combined and turned into a binary
|
|
457 spell file. All the preprocessing has been done, thus this file loads fast.
|
|
458 The binary spell file format is described in the source code (src/spell.c).
|
|
459 But only developers need to know about it.
|
221
|
460
|
237
|
461 The preprocessing also allows us to take the Myspell language files and modify
|
|
462 them before the Vim word list is made. The tools for this can be found in the
|
|
463 "src/spell" directory.
|
|
464
|
|
465
|
320
|
466 WORD LIST FORMAT *spell-dic-format*
|
237
|
467
|
|
468 A very short example, with line numbers:
|
221
|
469
|
237
|
470 1 1234
|
|
471 2 aan
|
|
472 3 Als
|
|
473 4 Etten-Leur
|
|
474 5 et al.
|
|
475 6 's-Gravenhage
|
|
476 7 's-Gravenhaags
|
|
477 8 bedel/P
|
|
478 9 kado/1
|
|
479 10 cadeau/2
|
|
480
|
314
|
481 The first line contains the number of words. Vim ignores it, but you do get
|
|
482 an error message if it's not there. *E760*
|
221
|
483
|
314
|
484 What follows is one word per line. There should be no white space before or
|
|
485 after the word.
|
237
|
486
|
|
487 When the word only has lower-case letters it will also match with the word
|
|
488 starting with an upper-case letter.
|
|
489
|
|
490 When the word includes an upper-case letter, this means the upper-case letter
|
|
491 is required at this position. The same word with a lower-case letter at this
|
|
492 position will not match. When some of the other letters are upper-case it will
|
|
493 not match either.
|
|
494
|
|
495 The same word with all upper-case characters will always be OK.
|
221
|
496
|
237
|
497 word list matches does not match ~
|
|
498 als als Als ALS ALs AlS aLs aLS
|
|
499 Als Als ALS als ALs AlS aLs aLS
|
|
500 ALS ALS als Als ALs AlS aLs aLS
|
|
501 AlS AlS ALS als Als ALs aLs aLS
|
221
|
502
|
314
|
503 The KEP affix ID can be used to specifically match a word with identical case
|
336
|
504 only, see below |spell-affix-KEP|.
|
308
|
505
|
237
|
506 Note in line 5 to 7 that non-word characters are used. You can include
|
|
507 any character in a word. When checking the text a word still only matches
|
|
508 when it appears with a non-word character before and after it. For Myspell a
|
|
509 word starting with a non-word character probably won't work.
|
|
510
|
|
511 After the word there is an optional slash and flags. Most of these flags are
|
|
512 letters that indicate the affixes that can be used with this word.
|
221
|
513
|
237
|
514 *spell-affix-vim*
|
314
|
515 A flag that Vim adds and is not in Myspell is the flag defined with KEP in the
|
308
|
516 affix file. This has the meaning that case matters. This can be used if the
|
|
517 word does not have the first letter in upper case at the start of a sentence.
|
314
|
518 Example (assuming that = was used for KEP):
|
237
|
519
|
|
520 word list matches does not match ~
|
|
521 's morgens/= 's morgens 'S morgens 's Morgens
|
|
522 's Morgens 's Morgens 'S morgens 's morgens
|
221
|
523
|
237
|
524 *spell-affix-mbyte*
|
|
525 The basic word list is normally in an 8-bit encoding, which is mentioned in
|
|
526 the affix file. The affix file must always be in the same encoding as the
|
|
527 word list. This is compatible with Myspell. For Vim the encoding may also be
|
|
528 something else, any encoding that "iconv" supports. The "SET" line must
|
|
529 specify the name of the encoding. When using a multi-byte encoding it's
|
|
530 possible to use more different affixes.
|
221
|
531
|
341
|
532
|
|
533 CHARACTER TABLES
|
258
|
534 *spell-affix-chars*
|
314
|
535 When using an 8-bit encoding the affix file should define what characters are
|
|
536 word characters (as specified with ENC). This is because the system where
|
|
537 ":mkspell" is used may not support a locale with this encoding and isalpha()
|
|
538 won't work. For example when using "cp1250" on Unix.
|
258
|
539
|
336
|
540 *E761* *E762* *spell-affix-FOL*
|
|
541 *spell-affix-LOW* *spell-affix-UPP*
|
258
|
542 Three lines in the affix file are needed. Simplistic example:
|
|
543
|
341
|
544 FOL áëñ ~
|
|
545 LOW áëñ ~
|
|
546 UPP ÁËÑ ~
|
258
|
547
|
|
548 All three lines must have exactly the same number of characters.
|
|
549
|
|
550 The "FOL" line specifies the case-folded characters. These are used to
|
|
551 compare words while ignoring case. For most encodings this is identical to
|
|
552 the lower case line.
|
|
553
|
|
554 The "LOW" line specifies the characters in lower-case. Mostly it's equal to
|
|
555 the "FOL" line.
|
|
556
|
|
557 The "UPP" line specifies the characters with upper-case. That is, a character
|
|
558 is upper-case where it's different from the character at the same position in
|
|
559 "FOL".
|
|
560
|
|
561 ASCII characters should be omitted, Vim always handles these in the same way.
|
|
562 When the encoding is UTF-8 no word characters need to be specified.
|
|
563
|
|
564 *E763*
|
353
|
565 Vim allows you to use spell checking for several languages in the same file.
|
|
566 You can list them in the 'spelllang' option. As a consequence all spell files
|
|
567 for the same encoding must use the same word characters, otherwise they can't
|
|
568 be combined without errors. If you get a warning that the word tables differ
|
|
569 you may need to generate the .spl file again with |:mkspell|. Check the FOL,
|
|
570 LOW and UPP lines in the used .aff file.
|
|
571
|
|
572 The XX.ascii.spl spell file generated with the "-ascii" argument will not
|
|
573 contain the table with characters, so that it can be combine with spell files
|
|
574 for any encoding. The .add.spl files also do not contain the table.
|
258
|
575
|
341
|
576
|
371
|
577 MID-WORD CHARACTERS
|
|
578 *spell-midword*
|
|
579 Some characters are only to be considered word characters if they are used in
|
|
580 between two ordinary word characters. An example is the single quote: It is
|
|
581 often used to put text in quotes, thus it can't be recognized as a word
|
|
582 character, but when it appears in between word characters it must be part of
|
|
583 the word. This is needed to detect a spelling error such as they'are. That
|
|
584 should be they're, but since "they" and "are" are words themselves that would
|
|
585 go unnoticed.
|
|
586
|
|
587 These characters are defined with MIDWORD in the .aff file:
|
|
588
|
|
589 MIDWORD '- ~
|
|
590
|
|
591
|
341
|
592 AFFIXES
|
336
|
593 *spell-affix-PFX* *spell-affix-SFX*
|
341
|
594 The usual PFX (prefix) and SFX (suffix) lines are supported (see the Myspell
|
371
|
595 documentation or the Aspell manual:
|
|
596 http://aspell.net/man-html/Affix-Compression.html).
|
|
597
|
|
598 Note that Myspell ignores any extra text after the relevant info. Vim
|
|
599 requires this text to start with a "#" so that mistakes don't go unnoticed.
|
|
600 Example:
|
|
601
|
|
602 SFX F 0 in [^i]n # Spion > Spionin ~
|
|
603 SFX F 0 nen in # Bauerin > Bauerinnen ~
|
341
|
604
|
371
|
605 An extra item for Vim is the "rare" flag. It must come after the other
|
|
606 fields, before a comment. When used then all words that use the affix will be
|
|
607 marked as rare words. Example:
|
|
608
|
|
609 PFX F 0 nene . rare ~
|
|
610 SFX F 0 oin n rare # hardly ever used ~
|
|
611
|
|
612 However, if the word also appears as a good word in another way it won't be
|
|
613 marked as rare.
|
336
|
614
|
341
|
615 *spell-affix-PFXPOSTPONE*
|
|
616 When an affix file has very many prefixes that apply to many words it's not
|
|
617 possible to build the whole word list in memory. This applies to Hebrew (a
|
|
618 list with all words is over a Gbyte). In that case applying prefixes must be
|
|
619 postponed. This makes spell checking slower. It is indicated by this keyword
|
|
620 in the .aff file:
|
|
621
|
|
622 PFXPOSTPONE ~
|
|
623
|
|
624 Only prefixes without a chop string can be postponed, prefixes with a chop
|
|
625 string will still be included in the word list.
|
|
626
|
|
627
|
|
628 KEEP-CASE WORDS
|
314
|
629 *spell-affix-KEP*
|
|
630 In the affix file a KEP line can be used to define the affix name used for
|
308
|
631 keep-case words. Example:
|
|
632
|
314
|
633 KEP = ~
|
308
|
634
|
|
635 See above for an example |spell-affix-vim|.
|
|
636
|
341
|
637
|
|
638 RARE WORDS
|
314
|
639 *spell-affix-RAR*
|
308
|
640 In the affix file a RAR line can be used to define the affix name used for
|
|
641 rare words. Example:
|
|
642
|
|
643 RAR ? ~
|
|
644
|
|
645 Rare words are highlighted differently from bad words. This is to be used for
|
|
646 words that are correct for the language, but are hardly ever used and could be
|
348
|
647 a typing mistake anyway. When the same word is found as good it won't be
|
|
648 highlighted as rare.
|
|
649
|
|
650
|
|
651 BAD WORDS
|
|
652 *spell-affix-BAD*
|
|
653 In the affix file a BAD line can be used to define the affix name used for
|
|
654 bad words. Example:
|
|
655
|
|
656 BAD ! ~
|
|
657
|
|
658 This can be used to exclude words that would otherwise be good. For example
|
371
|
659 "the the" in the .dic file:
|
|
660
|
|
661 the the/! ~
|
|
662
|
|
663 Once a word has been marked as bad it won't be undone by encountering the same
|
|
664 word as good.
|
308
|
665
|
|
666
|
323
|
667 REPLACEMENTS *spell-affix-REP*
|
|
668
|
|
669 In the affix file REP items can be used to define common mistakes. This is
|
|
670 used to make spelling suggestions. The items define the "from" text and the
|
|
671 "to" replacement. Example:
|
|
672
|
|
673 REP 4 ~
|
|
674 REP f ph ~
|
|
675 REP ph f ~
|
|
676 REP k ch ~
|
|
677 REP ch k ~
|
|
678
|
|
679 The first line specifies the number of REP lines following. Vim ignores it.
|
|
680
|
|
681
|
|
682 SIMILAR CHARACTERS *spell-affix-MAP*
|
|
683
|
|
684 In the affix file MAP items can be used to define letters that very much
|
|
685 alike. This is mostly used for a letter with different accents. This is used
|
|
686 to prefer suggestions with these letters substituted. Example:
|
|
687
|
|
688 MAP 2 ~
|
|
689 MAP eéëêè ~
|
|
690 MAP uüùúû ~
|
|
691
|
|
692 The first line specifies the number of MAP lines following. Vim ignores it.
|
|
693
|
336
|
694 A letter must only appear in one of the MAP items. It's a bit more efficient
|
|
695 if the first letter is ASCII or at least one without accents.
|
|
696
|
323
|
697
|
|
698 SOUNDS-A-LIKE *spell-affix-SAL*
|
|
699
|
|
700 In the affix file SAL items can be used to define the sounds-a-like mechanism
|
|
701 to be used. The main items define the "from" text and the "to" replacement.
|
|
702 Example:
|
|
703
|
|
704 SAL CIA X ~
|
|
705 SAL CH X ~
|
|
706 SAL C K ~
|
|
707 SAL K K ~
|
|
708
|
|
709 TODO: explain how it works.
|
|
710
|
|
711 There are a few special items:
|
|
712
|
|
713 SAL followup true ~
|
|
714 SAL collapse_result true ~
|
|
715 SAL remove_accents true ~
|
|
716
|
|
717 "1" has the same meaning as "true". Any other value means "false".
|
|
718
|
221
|
719 vim:tw=78:sw=4:ts=8:ft=help:norl:
|