blob: 606a030dc86c3fd3512907386a6f52353c8303e9 [file] [log] [blame]
Bram Moolenaar42eeac32005-06-29 22:40:58 +00001*spell.txt* For Vim version 7.0aa. Last change: 2005 Jun 29
Bram Moolenaar217ad922005-03-20 22:37:15 +00002
3
4 VIM REFERENCE MANUAL by Bram Moolenaar
5
6
7Spell checking *spell*
8
91. Quick start |spell-quickstart|
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000102. Generating a spell file |spell-mkspell|
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000113. Spell file format |spell-file-format|
Bram Moolenaar217ad922005-03-20 22:37:15 +000012
13{Vi does not have any of these commands}
14
15Spell checking is not available when the |+syntax| feature has been disabled
16at compile time.
17
18==============================================================================
191. Quick start *spell-quickstart*
20
21This command switches on spell checking: >
22
23 :setlocal spell spelllang=en_us
24
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +000025This switches on the 'spell' option and specifies to check for US English.
Bram Moolenaar217ad922005-03-20 22:37:15 +000026
27The words that are not recognized are highlighted with one of these:
Bram Moolenaar520470a2005-06-16 21:59:56 +000028 SpellBad word not recognized |hl-SpellBad|
29 SpellRare rare word |hl-SpellRare|
30 SpellLocal wrong spelling for selected region |hl-SpellLocal|
Bram Moolenaar217ad922005-03-20 22:37:15 +000031
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +000032Vim only checks words for spelling, there is no grammar check.
33
34To search for the next misspelled word:
35
36 *]s* *E756*
37]s Move to next misspelled word after the cursor.
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +000038 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|.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +000041
42 *[s*
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +000043[s Like "]s" but search backwards, find the misspelled
Bram Moolenaar30abd282005-06-22 22:35:10 +000044 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.
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +000047
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.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +000054
Bram Moolenaar217ad922005-03-20 22:37:15 +000055
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +000056To add words to your own word list: *E764*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000057
58 *zg*
59zg 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*
64zw 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
Bram Moolenaar520470a2005-06-16 21:59:56 +000068 *:spe* *:spellgood*
69:spe[llgood] {word} Add [word} as a good word to 'spellfile'.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000070
Bram Moolenaar520470a2005-06-16 21:59:56 +000071 *:spellw* *:spellwrong*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000072:spellw[rong] {word} Add [word} as a wrong (bad) word to 'spellfile'.
73
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000074After adding a word to 'spellfile' with the above commands its associated
75".spl" file will automatically be updated. If you edit 'spellfile' manually
76you need to use the |:mkspell| command. This sequence of commands mostly
77works well: >
78 :exe 'e ' . &spellfile
79< (make changes to the spell file) >
80 :mkspell! %
81
82More details about the 'spellfile' format below |spell-wordlist-format|.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000083
84
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +000085Finding suggestions for bad words:
86
87 *z?*
Bram Moolenaar30abd282005-06-22 22:35:10 +000088z? For the word under/after the cursor suggest correctly
89 spelled words. This also works to find alternative
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000090 for words that are not highlighted as bad words, e.g.,
91 when the word after it is bad.
Bram Moolenaar30abd282005-06-22 22:35:10 +000092 The results are sorted on similarity to the word
93 under/after the cursor.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +000094 This may take a long time. Hit CTRL-C when you are
95 bored.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000096 This does not work when there is a line break halfway
97 a bad word (e.g., "the the").
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +000098 You can enter the number of your choice or press
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000099 <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.
Bram Moolenaarf3bd51a2005-06-14 22:11:18 +0000104 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).
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000107 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
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +0000111 *: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
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000115The 'spellsuggest' option influences how the list of suggestions is generated
116and sorted. See |'spellsuggest'|.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000117
118
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000119PERFORMANCE
120
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +0000121Note that Vim does on-the-fly spell checking. To make this work fast the word
122list is loaded in memory. Thus this uses a lot of memory (1 Mbyte or more).
123There might also be a noticeable delay when the word list is loaded, which
124happens when 'spell' is set and when 'spelllang' is set while 'spell' was
125already set. To minimize the delay each word list is only loaded once, it
126is 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
128then too.
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000129
130
Bram Moolenaar217ad922005-03-20 22:37:15 +0000131REGIONS
132
133A word may be spelled differently in various regions. For example, English
134comes in (at least) these variants:
135
136 en all regions
Bram Moolenaar5c5474b2005-04-19 21:40:26 +0000137 en_au Australia
Bram Moolenaar217ad922005-03-20 22:37:15 +0000138 en_ca Canada
Bram Moolenaar5c5474b2005-04-19 21:40:26 +0000139 en_gb Great Britain
140 en_nz New Zealand
141 en_us USA
Bram Moolenaar217ad922005-03-20 22:37:15 +0000142
143Words that are not used in one region but are used in another region are
Bram Moolenaar520470a2005-06-16 21:59:56 +0000144highlighted with SpellLocal |hl-SpellLocal|.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000145
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000146Always use lowercase letters for the language and region names.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000147
Bram Moolenaar3638c682005-06-08 22:05:14 +0000148When adding a word with |zg| or another command it's always added for all
149regions. You can change that by manually editing the 'spellfile'. See
150|spell-wordlist-format|.
151
Bram Moolenaar217ad922005-03-20 22:37:15 +0000152
Bram Moolenaar3b506942005-06-23 22:36:45 +0000153SPELL FILES *spell-load*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000154
155Vim searches for spell files in the "spell" subdirectory of the directories in
Bram Moolenaar3638c682005-06-08 22:05:14 +0000156'runtimepath'. The name is: LL.EEE.spl, where:
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000157 LL the language name
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000158 EEE the value of 'encoding'
Bram Moolenaar217ad922005-03-20 22:37:15 +0000159
Bram Moolenaar3b506942005-06-23 22:36:45 +0000160The value for "LL" comes from 'spelllang', but excludes the region name.
161Examples:
162 'spelllang' LL ~
163 en_us en
164 en-rare en-rare
165 medical_ca medical
166
Bram Moolenaar3638c682005-06-08 22:05:14 +0000167Only the first file is loaded, the one that is first in 'runtimepath'. If
168this succeeds then additionally files with the name LL.EEE.add.spl are loaded.
169All the ones that are found are used.
170
Bram Moolenaar3b506942005-06-23 22:36:45 +0000171Additionally, the file related to 'spellfile' is loaded. This is the file
172that |zg| and |zw| add good and wrong words to.
173
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000174Exceptions:
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
Bram Moolenaar3638c682005-06-08 22:05:14 +0000180 is being edited. For the ".add" files the same name as the found main
181 spell file is used.
182
183For example, with these values:
184 'runtimepath' is "~/.vim,/usr/share/vim70,~/.vim/after"
185 'encoding' is "iso-8859-2"
186 'spelllang' is "pl"
187
188Vim will look for:
1891. ~/.vim/spell/pl.iso-8859-2.spl
1902. /usr/share/vim70/spell/pl.iso-8859-2.spl
1913. ~/.vim/spell/pl.iso-8859-2.add.spl
1924. /usr/share/vim70/spell/pl.iso-8859-2.add.spl
1935. ~/.vim/after/spell/pl.iso-8859-2.add.spl
194
195This assumes 1. is not found and 2. is found.
196
197If 'encoding' is "latin1" Vim will look for:
1981. ~/.vim/spell/pl.latin1.spl
1992. /usr/share/vim70/spell/pl.latin1.spl
2003. ~/.vim/after/spell/pl.latin1.spl
2014. ~/.vim/spell/pl.ascii.spl
2025. /usr/share/vim70/spell/pl.ascii.spl
2036. ~/.vim/after/spell/pl.ascii.spl
204
205This assumes none of them are found (Polish doesn't make sense when leaving
206out the non-ASCII characters).
Bram Moolenaar217ad922005-03-20 22:37:15 +0000207
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000208Spelling for EBCDIC is currently not supported.
209
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000210A 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
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000212with "iconv" will NOT work!
Bram Moolenaar217ad922005-03-20 22:37:15 +0000213
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000214 *E758* *E759*
215When loading a spell file Vim checks that it is properly formatted. If you
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000216get an error the file may be truncated, modified or intended for another Vim
217version.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000218
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000219
220WORDS
221
222Vim 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
224include characters like '-' in 'iskeyword'. The word characters do depend on
225'encoding'.
226
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000227The table with word characters is stored in the main .spl file. Therefore it
228matters what the current locale is when generating it! A .add.spl file does
Bram Moolenaarf461c8e2005-06-25 23:04:51 +0000229not contain a word table though.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000230
Bram Moolenaar3638c682005-06-08 22:05:14 +0000231A word that starts with a digit is always ignored. That includes hex numbers
232in the form 0xff and 0XFF.
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000233
234
Bram Moolenaar30abd282005-06-22 22:35:10 +0000235WORD COMBINATIONS
236
237It is possible to spell-check words that include a space. This is used to
238recognize words that are invalid when used by themselves, e.g. for "et al.".
239It can also be used to recognize "the the" and highlight it.
240
241The number of spaces is irrelevant. In most cases a line break may also
242appear. However, this makes it difficult to find out where to start checking
243for spelling mistakes. When you make a change to one line and only that line
244is redrawn Vim won't look in the previous line, thus when "et" is at the end
245of 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.
247Use |CTRL-L| to redraw right away. "[s" will also stop at a word combination
248with a line break.
249
250When encountering a line break Vim skips characters such as '*', '>' and '"',
251so that comments in C, shell and Vim code can be spell checked.
252
253
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +0000254SYNTAX HIGHLIGHTING *spell-syntax*
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000255
256Files that use syntax highlighting can specify where spell checking should be
257done:
258
Bram Moolenaar3638c682005-06-08 22:05:14 +00002591. everywhere default
2602. in specific items use "contains=@Spell"
2613. everywhere but specific items use "contains=@NoSpell"
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000262
Bram Moolenaar3638c682005-06-08 22:05:14 +0000263For the second method adding the @NoSpell cluster will disable spell checking
264again. This can be used, for example, to add @Spell to the comments of a
265program, and add @NoSpell for items that shouldn't be checked.
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000266
Bram Moolenaar30abd282005-06-22 22:35:10 +0000267
268VIM SCRIPTS
269
270If you want to write a Vim script that does something with spelling, you may
271find these functions useful:
272
273 spellbadword() find badly spelled word at the cursor
274 spellsuggest() get list of spelling suggestions
275
Bram Moolenaar217ad922005-03-20 22:37:15 +0000276==============================================================================
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002772. Generating a spell file *spell-mkspell*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000278
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000279Vim uses a binary file format for spelling. This greatly speeds up loading
280the word list and keeps it small.
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000281 *.aff* *.dic* *Myspell*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000282You can create a Vim spell file from the .aff and .dic files that Myspell
283uses. Myspell is used by OpenOffice.org and Mozilla. You should be able to
284find them here:
285 http://lingucomponent.openoffice.org/spell_dic.html
Bram Moolenaar30abd282005-06-22 22:35:10 +0000286You can also use a plain word list. The results are the same, the choice
287depends on what you find.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000288
Bram Moolenaare13305e2005-06-19 22:54:15 +0000289Make sure your current locale is set properly, otherwise Vim doesn't know what
290characters are upper/lower case letters. If the locale isn't available (e.g.,
291when using an MS-Windows codepage on Unix) add tables to the .aff file
Bram Moolenaar3b506942005-06-23 22:36:45 +0000292|spell-affix-chars|. If the .aff file doesn't define a table then the word
293table of the currently active spelling is used. If spelling is not active
294then Vim will try to guess.
Bram Moolenaare13305e2005-06-19 22:54:15 +0000295
Bram Moolenaar3b506942005-06-23 22:36:45 +0000296 *:mksp* *:mkspell*
297:mksp[ell][!] [-ascii] {outname} {inname} ...
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000298 Generate a Vim spell file word lists. Example: >
299 :mkspell nl nl_NL.words
Bram Moolenaar3b506942005-06-23 22:36:45 +0000300< *E751*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000301 When {outname} ends in ".spl" it is used as the output
302 file name. Otherwise it should be a language name,
Bram Moolenaar3b506942005-06-23 22:36:45 +0000303 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.
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000306
Bram Moolenaar520470a2005-06-16 21:59:56 +0000307 When the output file already exists [!] must be added
308 to overwrite it.
309
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000310 When the [-ascii] argument is present, words with
311 non-ascii characters are skipped. The resulting file
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000312 ends in "ascii.spl".
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000313
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
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000319 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*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000325 The REP and SAL items of the first .aff file where
326 they appear are used. |spell-affix-REP|
327 |spell-affix-SAL|
Bram Moolenaar217ad922005-03-20 22:37:15 +0000328
Bram Moolenaar30abd282005-06-22 22:35:10 +0000329 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
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000333 When the spell file was written all currently used
334 spell files will be reloaded.
335
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000336: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"
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000344 appended.
345
346Since you might want to change a Myspell word list for use with Vim the
347following procedure is recommended:
Bram Moolenaar217ad922005-03-20 22:37:15 +0000348
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00003491. Obtain the xx_YY.aff and xx_YY.dic files from Myspell.
3502. Make a copy of these files to xx_YY.orig.aff and xx_YY.orig.dic.
3513. Change the xx_YY.aff and xx_YY.dic files to remove bad words, add missing
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000352 words, define word characters with FOL/LOW/UPP, etc. The distributed
353 "src/spell/*.diff" files can be used.
3544. Set 'encoding' to the desired encoding and use |:mkspell| to generate the
355 Vim spell file.
3565. Try out the spell file with ":set spell spelllang=xx_YY".
Bram Moolenaar217ad922005-03-20 22:37:15 +0000357
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000358When the Myspell files are updated you can merge the differences:
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003591. Obtain the new Myspell files as xx_YY.new.aff and xx_UU.new.dic.
3602. Use Vimdiff to see what changed: >
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000361 vimdiff xx_YY.orig.dic xx_YY.new.dic
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003623. Take over the changes you like in xx_YY.dic.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000363 You may also need to change xx_YY.aff.
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003644. Rename xx_YY.new.dic to xx_YY.orig.dic and xx_YY.new.aff to xx_YY.new.aff.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000365
Bram Moolenaar3b506942005-06-23 22:36:45 +0000366
367SPELL FILE DUMP
368
369If for some reason you want to check what words are supported by the currently
370used 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
378The format of the word list is used |spell-wordlist-format|. You should be
379able to read it with ":mkspell" to generate one .spl file that includes all
380the words.
381
382Only words for the current region are included. No "/regions" line is
383generated.
384
385Comment lines are used to indicate which .spl file the words came from.
386
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000387==============================================================================
Bram Moolenaar3b506942005-06-23 22:36:45 +00003883. Spell file format *spell-file-format*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000389
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000390This is the format of the files that are used by the person who creates and
391maintains a word list.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000392
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000393Note that we avoid the word "dictionary" here. That is because the goal of
394spell checking differs from writing a dictionary (as in the book). For
395spelling we need a list of words that are OK, thus need not to be highlighted.
396Names will not appear in a dictionary, but do appear in a word list. And
397some old words are rarely used and are common misspellings. These do appear
398in a dictionary but not in a word list.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000399
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000400There are two formats: one with affix compression and one without. The files
401with affix compression are used by Myspell (Mozilla and OpenOffice.org). This
402requires two files, one with .aff and one with .dic extension. The second
403format is a list of words.
404
405
Bram Moolenaar3638c682005-06-08 22:05:14 +0000406FORMAT OF WORD LIST *spell-wordlist-format*
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000407
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000408The words must appear one per line. That is all that is required.
409Additionally the following items are recognized:
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000410- Empty and blank lines are ignored.
411- Lines starting with a # are ignored (comment lines).
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000412- 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'.
Bram Moolenaar3638c682005-06-08 22:05:14 +0000415- 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!
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000419- 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 "/=!".
Bram Moolenaar3638c682005-06-08 22:05:14 +0000423- Digits after "/" indicate the regions in which the word is valid. If no
424 regions are specified the word is valid in all regions.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000425- 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).
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000427
Bram Moolenaar3638c682005-06-08 22:05:14 +0000428Example:
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"
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000435 /!vim bad word
Bram Moolenaar3638c682005-06-08 22:05:14 +0000436 /?3Campbell rare word in region 3 "gb"
437 /='s mornings keep-case word
438
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000439
440FORMAT WITH AFFIX COMPRESSION
441
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000442There are two files: the basic word list and an affix file. The affixes are
443used to modify the basic words to get the full word list. This significantly
444reduces the number of words, especially for a language like Polish. This is
445called affix compression.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000446
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000447The format for the affix and word list files is mostly identical to what
448Myspell uses (the spell checker of Mozilla and OpenOffice.org). A description
449can be found here:
450 http://lingucomponent.openoffice.org/affix.readme ~
451Note that affixes are case sensitive, this isn't obvious from the description.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000452
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000453Vim supports a few extras. Hopefully Myspell will support these too some day.
454See |spell-affix-vim|.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000455
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000456The basic word list and the affix file are combined and turned into a binary
457spell file. All the preprocessing has been done, thus this file loads fast.
458The binary spell file format is described in the source code (src/spell.c).
459But only developers need to know about it.
460
461The preprocessing also allows us to take the Myspell language files and modify
462them before the Vim word list is made. The tools for this can be found in the
463"src/spell" directory.
464
465
Bram Moolenaar3638c682005-06-08 22:05:14 +0000466WORD LIST FORMAT *spell-dic-format*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000467
468A very short example, with line numbers:
469
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
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000481The first line contains the number of words. Vim ignores it, but you do get
482an error message if it's not there. *E760*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000483
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000484What follows is one word per line. There should be no white space before or
485after the word.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000486
487When the word only has lower-case letters it will also match with the word
488starting with an upper-case letter.
489
490When the word includes an upper-case letter, this means the upper-case letter
491is required at this position. The same word with a lower-case letter at this
492position will not match. When some of the other letters are upper-case it will
493not match either.
494
495The same word with all upper-case characters will always be OK.
496
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
502
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000503The KEP affix ID can be used to specifically match a word with identical case
Bram Moolenaare7566042005-06-17 22:00:15 +0000504only, see below |spell-affix-KEP|.
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000505
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000506Note in line 5 to 7 that non-word characters are used. You can include
507any character in a word. When checking the text a word still only matches
508when it appears with a non-word character before and after it. For Myspell a
509word starting with a non-word character probably won't work.
510
511After the word there is an optional slash and flags. Most of these flags are
512letters that indicate the affixes that can be used with this word.
513
514 *spell-affix-vim*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000515A flag that Vim adds and is not in Myspell is the flag defined with KEP in the
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000516affix file. This has the meaning that case matters. This can be used if the
517word does not have the first letter in upper case at the start of a sentence.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000518Example (assuming that = was used for KEP):
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000519
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
523
524 *spell-affix-mbyte*
525The basic word list is normally in an 8-bit encoding, which is mentioned in
526the affix file. The affix file must always be in the same encoding as the
527word list. This is compatible with Myspell. For Vim the encoding may also be
528something else, any encoding that "iconv" supports. The "SET" line must
529specify the name of the encoding. When using a multi-byte encoding it's
530possible to use more different affixes.
531
Bram Moolenaare13305e2005-06-19 22:54:15 +0000532
533CHARACTER TABLES
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000534 *spell-affix-chars*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000535When using an 8-bit encoding the affix file should define what characters are
536word 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()
538won't work. For example when using "cp1250" on Unix.
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000539
Bram Moolenaare7566042005-06-17 22:00:15 +0000540 *E761* *E762* *spell-affix-FOL*
541 *spell-affix-LOW* *spell-affix-UPP*
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000542Three lines in the affix file are needed. Simplistic example:
543
Bram Moolenaare13305e2005-06-19 22:54:15 +0000544 FOL áëñ ~
545 LOW áëñ ~
546 UPP ÁËÑ ~
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000547
548All three lines must have exactly the same number of characters.
549
550The "FOL" line specifies the case-folded characters. These are used to
551compare words while ignoring case. For most encodings this is identical to
552the lower case line.
553
554The "LOW" line specifies the characters in lower-case. Mostly it's equal to
555the "FOL" line.
556
557The "UPP" line specifies the characters with upper-case. That is, a character
558is upper-case where it's different from the character at the same position in
559"FOL".
560
561ASCII characters should be omitted, Vim always handles these in the same way.
562When the encoding is UTF-8 no word characters need to be specified.
563
564 *E763*
Bram Moolenaar3b506942005-06-23 22:36:45 +0000565Vim allows you to use spell checking for several languages in the same file.
566You can list them in the 'spelllang' option. As a consequence all spell files
567for the same encoding must use the same word characters, otherwise they can't
568be combined without errors. If you get a warning that the word tables differ
569you may need to generate the .spl file again with |:mkspell|. Check the FOL,
570LOW and UPP lines in the used .aff file.
571
572The XX.ascii.spl spell file generated with the "-ascii" argument will not
573contain the table with characters, so that it can be combine with spell files
574for any encoding. The .add.spl files also do not contain the table.
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000575
Bram Moolenaare7566042005-06-17 22:00:15 +0000576
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000577MID-WORD CHARACTERS
578 *spell-midword*
579Some characters are only to be considered word characters if they are used in
580between two ordinary word characters. An example is the single quote: It is
581often used to put text in quotes, thus it can't be recognized as a word
582character, but when it appears in between word characters it must be part of
583the word. This is needed to detect a spelling error such as they'are. That
584should be they're, but since "they" and "are" are words themselves that would
585go unnoticed.
586
587These characters are defined with MIDWORD in the .aff file:
588
589 MIDWORD '- ~
590
591
Bram Moolenaare13305e2005-06-19 22:54:15 +0000592AFFIXES
593 *spell-affix-PFX* *spell-affix-SFX*
594The usual PFX (prefix) and SFX (suffix) lines are supported (see the Myspell
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000595documentation or the Aspell manual:
596http://aspell.net/man-html/Affix-Compression.html).
Bram Moolenaare13305e2005-06-19 22:54:15 +0000597
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000598Note that Myspell ignores any extra text after the relevant info. Vim
599requires this text to start with a "#" so that mistakes don't go unnoticed.
600Example:
601
602 SFX F 0 in [^i]n # Spion > Spionin ~
603 SFX F 0 nen in # Bauerin > Bauerinnen ~
604
605An extra item for Vim is the "rare" flag. It must come after the other
606fields, before a comment. When used then all words that use the affix will be
607marked as rare words. Example:
608
609 PFX F 0 nene . rare ~
610 SFX F 0 oin n rare # hardly ever used ~
611
612However, if the word also appears as a good word in another way it won't be
613marked as rare.
Bram Moolenaare13305e2005-06-19 22:54:15 +0000614
615 *spell-affix-PFXPOSTPONE*
616When an affix file has very many prefixes that apply to many words it's not
617possible to build the whole word list in memory. This applies to Hebrew (a
618list with all words is over a Gbyte). In that case applying prefixes must be
619postponed. This makes spell checking slower. It is indicated by this keyword
620in the .aff file:
621
622 PFXPOSTPONE ~
623
624Only prefixes without a chop string can be postponed, prefixes with a chop
625string will still be included in the word list.
626
627
628KEEP-CASE WORDS
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000629 *spell-affix-KEP*
630In the affix file a KEP line can be used to define the affix name used for
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000631keep-case words. Example:
632
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000633 KEP = ~
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000634
635See above for an example |spell-affix-vim|.
636
Bram Moolenaare13305e2005-06-19 22:54:15 +0000637
638RARE WORDS
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000639 *spell-affix-RAR*
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000640In the affix file a RAR line can be used to define the affix name used for
641rare words. Example:
642
643 RAR ? ~
644
645Rare words are highlighted differently from bad words. This is to be used for
646words that are correct for the language, but are hardly ever used and could be
Bram Moolenaar30abd282005-06-22 22:35:10 +0000647a typing mistake anyway. When the same word is found as good it won't be
648highlighted as rare.
649
650
651BAD WORDS
652 *spell-affix-BAD*
653In the affix file a BAD line can be used to define the affix name used for
654bad words. Example:
655
656 BAD ! ~
657
658This can be used to exclude words that would otherwise be good. For example
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000659"the the" in the .dic file:
660
661 the the/! ~
662
663Once a word has been marked as bad it won't be undone by encountering the same
664word as good.
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000665
666
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000667REPLACEMENTS *spell-affix-REP*
668
669In the affix file REP items can be used to define common mistakes. This is
670used 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
679The first line specifies the number of REP lines following. Vim ignores it.
680
681
682SIMILAR CHARACTERS *spell-affix-MAP*
683
684In the affix file MAP items can be used to define letters that very much
685alike. This is mostly used for a letter with different accents. This is used
686to prefer suggestions with these letters substituted. Example:
687
688 MAP 2 ~
689 MAP eéëêè ~
690 MAP uüùúû ~
691
692The first line specifies the number of MAP lines following. Vim ignores it.
693
Bram Moolenaare7566042005-06-17 22:00:15 +0000694A letter must only appear in one of the MAP items. It's a bit more efficient
695if the first letter is ASCII or at least one without accents.
696
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000697
698SOUNDS-A-LIKE *spell-affix-SAL*
699
700In the affix file SAL items can be used to define the sounds-a-like mechanism
701to be used. The main items define the "from" text and the "to" replacement.
702Example:
703
704 SAL CIA X ~
705 SAL CH X ~
706 SAL C K ~
707 SAL K K ~
708
Bram Moolenaar42eeac32005-06-29 22:40:58 +0000709An explantion how it works can be found in the Aspell manual:
710http://aspell.net/man-html/Phonetic-Code.html.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000711
712There are a few special items:
713
714 SAL followup true ~
715 SAL collapse_result true ~
716 SAL remove_accents true ~
717
718"1" has the same meaning as "true". Any other value means "false".
719
Bram Moolenaar42eeac32005-06-29 22:40:58 +0000720
721SIMPLE SOUNDFOLDING *spell-affix-SOFOFROM* *spell-affix-SOFOTO*
722
723The SAL mechanism is complex and slow. A simpler mechanism is mapping all
724characters to another character, mapping similar sounding characters to the
725same character. At the same time this does case folding. You can not have
726SAL items at the same time.
727
728There are two items required: one to speficy the characters that are mapped
729and one that specifies the characters they are mapped to. They must have
730exactly the same number of characters. Example:
731
732 SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~
733 SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkes ~
734
735In the example all vowels are mapped to the same character 'e'. Another
736method is to leave out all vowels. Some characters that sound nearly the same
737and are often mixed up, such as 'm' and 'n', are mapped to the same character.
738Don't do this too much, all words will start looking alike.
739
740Characters that do not appear in SOFOFROM will be left out, except that all
741white space is replaced by one space. Sequences of the same character in
742SOFOFROM are replaced by one.
743
744You can use the |soundfold()| function to try out the results. Or set the
745'verbose' option to see the score in the output of the |z?| command.
746
747
Bram Moolenaar217ad922005-03-20 22:37:15 +0000748 vim:tw=78:sw=4:ts=8:ft=help:norl: