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