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