blob: 0ca0e0b15d4dc032840595e5a0f3032a923cdb0a [file] [log] [blame]
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +00001*spell.txt* For Vim version 7.0aa. Last change: 2005 Jul 01
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 Moolenaard042c562005-06-30 22:04:15 +0000102. Remarks on spell checking |spell-remarks|
113. Generating a spell file |spell-mkspell|
124. Spell file format |spell-file-format|
Bram Moolenaar217ad922005-03-20 22:37:15 +000013
14{Vi does not have any of these commands}
15
16Spell checking is not available when the |+syntax| feature has been disabled
17at compile time.
18
19==============================================================================
201. Quick start *spell-quickstart*
21
22This command switches on spell checking: >
23
24 :setlocal spell spelllang=en_us
25
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +000026This switches on the 'spell' option and specifies to check for US English.
Bram Moolenaar217ad922005-03-20 22:37:15 +000027
28The words that are not recognized are highlighted with one of these:
Bram Moolenaar520470a2005-06-16 21:59:56 +000029 SpellBad word not recognized |hl-SpellBad|
30 SpellRare rare word |hl-SpellRare|
31 SpellLocal wrong spelling for selected region |hl-SpellLocal|
Bram Moolenaar217ad922005-03-20 22:37:15 +000032
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +000033Vim only checks words for spelling, there is no grammar check.
34
35To search for the next misspelled word:
36
37 *]s* *E756*
38]s Move to next misspelled word after the cursor.
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +000039 A count before the command can be used to repeat.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +000040
41 *[s*
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +000042[s Like "]s" but search backwards, find the misspelled
Bram Moolenaar30abd282005-06-22 22:35:10 +000043 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.
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +000046
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.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +000053
Bram Moolenaar217ad922005-03-20 22:37:15 +000054
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +000055To add words to your own word list: *E764*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000056
57 *zg*
58zg 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
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000062 *zG*
63zG Like "zg" but add the word to the internal word list.
64
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000065 *zw*
66zw 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
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000070 *zW*
71zW Like "zw" but add the word to the internal word list.
72
Bram Moolenaar520470a2005-06-16 21:59:56 +000073 *:spe* *:spellgood*
74:spe[llgood] {word} Add [word} as a good word to 'spellfile'.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000075
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000076:spe[llgood]! {word} Add [word} as a good word to the internal word list.
77
Bram Moolenaar520470a2005-06-16 21:59:56 +000078 *:spellw* *:spellwrong*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000079:spellw[rong] {word} Add [word} as a wrong (bad) word to 'spellfile'.
80
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000081:spellw[rong]! {word} Add [word} as a wrong (bad) word to the internal word
82 list.
83
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000084After adding a word to 'spellfile' with the above commands its associated
Bram Moolenaard042c562005-06-30 22:04:15 +000085".spl" file will automatically be updated and reloaded. If you change
86'spellfile' manually you need to use the |:mkspell| command. This sequence of
87commands mostly works well: >
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000088 :exe 'e ' . &spellfile
89< (make changes to the spell file) >
90 :mkspell! %
91
92More details about the 'spellfile' format below |spell-wordlist-format|.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000093
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000094The internal word list is used for all buffers where 'spell' is set. It is
95not stored, it is lost when you exit Vim. It is also cleared when 'encoding'
96is set.
97
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000098
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +000099Finding suggestions for bad words:
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000100 *z?*
Bram Moolenaar30abd282005-06-22 22:35:10 +0000101z? For the word under/after the cursor suggest correctly
Bram Moolenaard042c562005-06-30 22:04:15 +0000102 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.
Bram Moolenaar30abd282005-06-22 22:35:10 +0000105 The results are sorted on similarity to the word
106 under/after the cursor.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000107 This may take a long time. Hit CTRL-C when you are
108 bored.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +0000109 This does not work when there is a line break halfway
110 a bad word (e.g., "the the").
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000111 You can enter the number of your choice or press
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +0000112 <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
Bram Moolenaard042c562005-06-30 22:04:15 +0000115 are no line wraps). Click on the first (header) line
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +0000116 to cancel.
Bram Moolenaarf3bd51a2005-06-14 22:11:18 +0000117 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).
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000120 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
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +0000124 *: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
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000128The 'spellsuggest' option influences how the list of suggestions is generated
129and sorted. See |'spellsuggest'|.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000130
Bram Moolenaard042c562005-06-30 22:04:15 +0000131==============================================================================
1322. Remarks on spell checking *spell-remarks*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000133
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000134PERFORMANCE
135
Bram Moolenaard042c562005-06-30 22:04:15 +0000136Vim does on-the-fly spell checking. To make this work fast the word list is
137loaded in memory. Thus this uses a lot of memory (1 Mbyte or more). There
138might also be a noticeable delay when the word list is loaded, which happens
139when 'spell' is set and when 'spelllang' is set while 'spell' was already set.
140To minimize the delay each word list is only loaded once, it is not deleted
141when 'spelllang' is made empty or 'spell' is reset. When 'encoding' is set
142all the word lists are reloaded, thus you may notice a delay then too.
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000143
144
Bram Moolenaar217ad922005-03-20 22:37:15 +0000145REGIONS
146
147A word may be spelled differently in various regions. For example, English
148comes in (at least) these variants:
149
150 en all regions
Bram Moolenaar5c5474b2005-04-19 21:40:26 +0000151 en_au Australia
Bram Moolenaar217ad922005-03-20 22:37:15 +0000152 en_ca Canada
Bram Moolenaar5c5474b2005-04-19 21:40:26 +0000153 en_gb Great Britain
154 en_nz New Zealand
155 en_us USA
Bram Moolenaar217ad922005-03-20 22:37:15 +0000156
157Words that are not used in one region but are used in another region are
Bram Moolenaar520470a2005-06-16 21:59:56 +0000158highlighted with SpellLocal |hl-SpellLocal|.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000159
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000160Always use lowercase letters for the language and region names.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000161
Bram Moolenaar3638c682005-06-08 22:05:14 +0000162When adding a word with |zg| or another command it's always added for all
163regions. You can change that by manually editing the 'spellfile'. See
164|spell-wordlist-format|.
165
Bram Moolenaar217ad922005-03-20 22:37:15 +0000166
Bram Moolenaar3b506942005-06-23 22:36:45 +0000167SPELL FILES *spell-load*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000168
169Vim searches for spell files in the "spell" subdirectory of the directories in
Bram Moolenaar3638c682005-06-08 22:05:14 +0000170'runtimepath'. The name is: LL.EEE.spl, where:
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000171 LL the language name
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000172 EEE the value of 'encoding'
Bram Moolenaar217ad922005-03-20 22:37:15 +0000173
Bram Moolenaar3b506942005-06-23 22:36:45 +0000174The value for "LL" comes from 'spelllang', but excludes the region name.
175Examples:
176 'spelllang' LL ~
177 en_us en
178 en-rare en-rare
179 medical_ca medical
180
Bram Moolenaar3638c682005-06-08 22:05:14 +0000181Only the first file is loaded, the one that is first in 'runtimepath'. If
182this succeeds then additionally files with the name LL.EEE.add.spl are loaded.
183All the ones that are found are used.
184
Bram Moolenaar3b506942005-06-23 22:36:45 +0000185Additionally, the file related to 'spellfile' is loaded. This is the file
186that |zg| and |zw| add good and wrong words to.
187
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000188Exceptions:
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
Bram Moolenaar3638c682005-06-08 22:05:14 +0000194 is being edited. For the ".add" files the same name as the found main
195 spell file is used.
196
197For example, with these values:
198 'runtimepath' is "~/.vim,/usr/share/vim70,~/.vim/after"
199 'encoding' is "iso-8859-2"
200 'spelllang' is "pl"
201
202Vim will look for:
2031. ~/.vim/spell/pl.iso-8859-2.spl
2042. /usr/share/vim70/spell/pl.iso-8859-2.spl
2053. ~/.vim/spell/pl.iso-8859-2.add.spl
2064. /usr/share/vim70/spell/pl.iso-8859-2.add.spl
2075. ~/.vim/after/spell/pl.iso-8859-2.add.spl
208
209This assumes 1. is not found and 2. is found.
210
211If 'encoding' is "latin1" Vim will look for:
2121. ~/.vim/spell/pl.latin1.spl
2132. /usr/share/vim70/spell/pl.latin1.spl
2143. ~/.vim/after/spell/pl.latin1.spl
2154. ~/.vim/spell/pl.ascii.spl
2165. /usr/share/vim70/spell/pl.ascii.spl
2176. ~/.vim/after/spell/pl.ascii.spl
218
219This assumes none of them are found (Polish doesn't make sense when leaving
220out the non-ASCII characters).
Bram Moolenaar217ad922005-03-20 22:37:15 +0000221
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000222Spelling for EBCDIC is currently not supported.
223
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000224A 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
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000226with "iconv" will NOT work!
Bram Moolenaar217ad922005-03-20 22:37:15 +0000227
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000228 *E758* *E759*
229When loading a spell file Vim checks that it is properly formatted. If you
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000230get an error the file may be truncated, modified or intended for another Vim
231version.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000232
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000233
234WORDS
235
236Vim 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
238include characters like '-' in 'iskeyword'. The word characters do depend on
239'encoding'.
240
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000241The table with word characters is stored in the main .spl file. Therefore it
242matters what the current locale is when generating it! A .add.spl file does
Bram Moolenaarf461c8e2005-06-25 23:04:51 +0000243not contain a word table though.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000244
Bram Moolenaar3638c682005-06-08 22:05:14 +0000245A word that starts with a digit is always ignored. That includes hex numbers
246in the form 0xff and 0XFF.
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000247
248
Bram Moolenaar30abd282005-06-22 22:35:10 +0000249WORD COMBINATIONS
250
251It is possible to spell-check words that include a space. This is used to
252recognize words that are invalid when used by themselves, e.g. for "et al.".
253It can also be used to recognize "the the" and highlight it.
254
255The number of spaces is irrelevant. In most cases a line break may also
256appear. However, this makes it difficult to find out where to start checking
257for spelling mistakes. When you make a change to one line and only that line
258is redrawn Vim won't look in the previous line, thus when "et" is at the end
259of 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.
261Use |CTRL-L| to redraw right away. "[s" will also stop at a word combination
262with a line break.
263
264When encountering a line break Vim skips characters such as '*', '>' and '"',
265so that comments in C, shell and Vim code can be spell checked.
266
267
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +0000268SYNTAX HIGHLIGHTING *spell-syntax*
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000269
270Files that use syntax highlighting can specify where spell checking should be
271done:
272
Bram Moolenaar3638c682005-06-08 22:05:14 +00002731. everywhere default
2742. in specific items use "contains=@Spell"
2753. everywhere but specific items use "contains=@NoSpell"
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000276
Bram Moolenaar3638c682005-06-08 22:05:14 +0000277For the second method adding the @NoSpell cluster will disable spell checking
278again. This can be used, for example, to add @Spell to the comments of a
279program, and add @NoSpell for items that shouldn't be checked.
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000280
Bram Moolenaar30abd282005-06-22 22:35:10 +0000281
282VIM SCRIPTS
283
284If you want to write a Vim script that does something with spelling, you may
285find these functions useful:
286
287 spellbadword() find badly spelled word at the cursor
288 spellsuggest() get list of spelling suggestions
Bram Moolenaard042c562005-06-30 22:04:15 +0000289 soundfold() get the sound-a-like version of a word
Bram Moolenaar30abd282005-06-22 22:35:10 +0000290
Bram Moolenaar217ad922005-03-20 22:37:15 +0000291==============================================================================
Bram Moolenaard042c562005-06-30 22:04:15 +00002923. Generating a spell file *spell-mkspell*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000293
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000294Vim uses a binary file format for spelling. This greatly speeds up loading
295the word list and keeps it small.
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000296 *.aff* *.dic* *Myspell*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000297You can create a Vim spell file from the .aff and .dic files that Myspell
298uses. Myspell is used by OpenOffice.org and Mozilla. You should be able to
299find them here:
300 http://lingucomponent.openoffice.org/spell_dic.html
Bram Moolenaar30abd282005-06-22 22:35:10 +0000301You can also use a plain word list. The results are the same, the choice
Bram Moolenaard042c562005-06-30 22:04:15 +0000302depends on what word lists you can find.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000303
Bram Moolenaare13305e2005-06-19 22:54:15 +0000304Make sure your current locale is set properly, otherwise Vim doesn't know what
305characters are upper/lower case letters. If the locale isn't available (e.g.,
306when using an MS-Windows codepage on Unix) add tables to the .aff file
Bram Moolenaar3b506942005-06-23 22:36:45 +0000307|spell-affix-chars|. If the .aff file doesn't define a table then the word
308table of the currently active spelling is used. If spelling is not active
309then Vim will try to guess.
Bram Moolenaare13305e2005-06-19 22:54:15 +0000310
Bram Moolenaar3b506942005-06-23 22:36:45 +0000311 *:mksp* *:mkspell*
312:mksp[ell][!] [-ascii] {outname} {inname} ...
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000313 Generate a Vim spell file word lists. Example: >
Bram Moolenaard042c562005-06-30 22:04:15 +0000314 :mkspell /tmp/nl nl_NL.words
Bram Moolenaar3b506942005-06-23 22:36:45 +0000315< *E751*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000316 When {outname} ends in ".spl" it is used as the output
317 file name. Otherwise it should be a language name,
Bram Moolenaar3b506942005-06-23 22:36:45 +0000318 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.
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000321
Bram Moolenaard042c562005-06-30 22:04:15 +0000322 When the output file already exists [!] must be used
Bram Moolenaar520470a2005-06-16 21:59:56 +0000323 to overwrite it.
324
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000325 When the [-ascii] argument is present, words with
326 non-ascii characters are skipped. The resulting file
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000327 ends in "ascii.spl".
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000328
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
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000334 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*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000340 The REP and SAL items of the first .aff file where
341 they appear are used. |spell-affix-REP|
342 |spell-affix-SAL|
Bram Moolenaar217ad922005-03-20 22:37:15 +0000343
Bram Moolenaar30abd282005-06-22 22:35:10 +0000344 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
Bram Moolenaard042c562005-06-30 22:04:15 +0000348 After the spell file was written and it was being used
349 in a buffer it will be reloaded automatically.
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000350
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000351:mksp[ell] [-ascii] {name}.{enc}.add
352 Like ":mkspell" above, using {name}.{enc}.add as the
Bram Moolenaard042c562005-06-30 22:04:15 +0000353 input file and producing an output file in the same
354 directory that has ".spl" appended.
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000355
356:mksp[ell] [-ascii] {name}
357 Like ":mkspell" above, using {name} as the input file
Bram Moolenaard042c562005-06-30 22:04:15 +0000358 and producing an output file in the same directory
359 that has ".{enc}.spl" appended.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000360
361Since you might want to change a Myspell word list for use with Vim the
362following procedure is recommended:
Bram Moolenaar217ad922005-03-20 22:37:15 +0000363
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00003641. Obtain the xx_YY.aff and xx_YY.dic files from Myspell.
3652. Make a copy of these files to xx_YY.orig.aff and xx_YY.orig.dic.
3663. Change the xx_YY.aff and xx_YY.dic files to remove bad words, add missing
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000367 words, define word characters with FOL/LOW/UPP, etc. The distributed
368 "src/spell/*.diff" files can be used.
Bram Moolenaard042c562005-06-30 22:04:15 +00003694. Start Vim with the right locale and use |:mkspell| to generate the Vim
370 spell file.
3715. 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.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000374
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000375When the Myspell files are updated you can merge the differences:
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003761. Obtain the new Myspell files as xx_YY.new.aff and xx_UU.new.dic.
3772. Use Vimdiff to see what changed: >
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000378 vimdiff xx_YY.orig.dic xx_YY.new.dic
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003793. Take over the changes you like in xx_YY.dic.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000380 You may also need to change xx_YY.aff.
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00003814. 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 +0000382
Bram Moolenaar3b506942005-06-23 22:36:45 +0000383
384SPELL FILE DUMP
385
386If for some reason you want to check what words are supported by the currently
387used 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.
Bram Moolenaard042c562005-06-30 22:04:15 +0000392 Note: For some languages the result may be enormous,
393 causing Vim to run out of memory.
Bram Moolenaar3b506942005-06-23 22:36:45 +0000394
395The format of the word list is used |spell-wordlist-format|. You should be
396able to read it with ":mkspell" to generate one .spl file that includes all
397the words.
398
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000399When all entries to 'spelllang' use the same regions or no regions at all then
400the region information is included in the dumped words. Otherwise only words
401for the current region are included and no "/regions" line is generated.
Bram Moolenaar3b506942005-06-23 22:36:45 +0000402
Bram Moolenaard042c562005-06-30 22:04:15 +0000403Comment lines with the name of the .spl file are used as a header above the
404words that were generated from that .spl file.
Bram Moolenaar3b506942005-06-23 22:36:45 +0000405
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000406==============================================================================
Bram Moolenaard042c562005-06-30 22:04:15 +00004074. Spell file format *spell-file-format*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000408
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000409This is the format of the files that are used by the person who creates and
410maintains a word list.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000411
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000412Note that we avoid the word "dictionary" here. That is because the goal of
413spell checking differs from writing a dictionary (as in the book). For
Bram Moolenaard042c562005-06-30 22:04:15 +0000414spelling we need a list of words that are OK, thus should not to be
415highlighted. Person and company names will not appear in a dictionary, but do
416appear in a word list. And some old words are rarely used while they are
417common misspellings. These do appear in a dictionary but not in a word list.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000418
Bram Moolenaard042c562005-06-30 22:04:15 +0000419There are two formats: A straigth list of words and a list using affix
420compression. The files with affix compression are used by Myspell (Mozilla
421and OpenOffice.org). This requires two files, one with .aff and one with .dic
422extension.
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000423
424
Bram Moolenaard042c562005-06-30 22:04:15 +0000425FORMAT OF STRAIGHT WORD LIST *spell-wordlist-format*
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000426
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000427The words must appear one per line. That is all that is required.
Bram Moolenaard042c562005-06-30 22:04:15 +0000428
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000429Additionally the following items are recognized:
Bram Moolenaard042c562005-06-30 22:04:15 +0000430
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000431- Empty and blank lines are ignored.
Bram Moolenaard042c562005-06-30 22:04:15 +0000432
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000433- Lines starting with a # are ignored (comment lines).
Bram Moolenaard042c562005-06-30 22:04:15 +0000434
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000435- 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
Bram Moolenaard042c562005-06-30 22:04:15 +0000437 to setup conversion from the specified encoding to 'encoding'. Thus you can
438 use one word list for several target encodings.
439
Bram Moolenaar3638c682005-06-08 22:05:14 +0000440- 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".
Bram Moolenaard042c562005-06-30 22:04:15 +0000443 In an addition word list the region names should be equal to the main word
444 list!
445
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000446- 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).
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000448
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000449- 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
Bram Moolenaar3638c682005-06-08 22:05:14 +0000456Example:
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
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000462 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
Bram Moolenaar3638c682005-06-08 22:05:14 +0000466
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000467
468FORMAT WITH AFFIX COMPRESSION
469
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000470There are two files: the basic word list and an affix file. The affixes are
471used to modify the basic words to get the full word list. This significantly
472reduces the number of words, especially for a language like Polish. This is
473called affix compression.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000474
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000475The format for the affix and word list files is mostly identical to what
476Myspell uses (the spell checker of Mozilla and OpenOffice.org). A description
477can be found here:
478 http://lingucomponent.openoffice.org/affix.readme ~
479Note that affixes are case sensitive, this isn't obvious from the description.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000480
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000481Vim supports a few extras. Hopefully Myspell will support these too some day.
482See |spell-affix-vim|.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000483
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000484The basic word list and the affix file are combined and turned into a binary
485spell file. All the preprocessing has been done, thus this file loads fast.
486The binary spell file format is described in the source code (src/spell.c).
487But only developers need to know about it.
488
489The preprocessing also allows us to take the Myspell language files and modify
490them before the Vim word list is made. The tools for this can be found in the
491"src/spell" directory.
492
493
Bram Moolenaar3638c682005-06-08 22:05:14 +0000494WORD LIST FORMAT *spell-dic-format*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000495
496A very short example, with line numbers:
497
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
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000509The first line contains the number of words. Vim ignores it, but you do get
510an error message if it's not there. *E760*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000511
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000512What follows is one word per line. There should be no white space before or
513after the word.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000514
515When the word only has lower-case letters it will also match with the word
516starting with an upper-case letter.
517
518When the word includes an upper-case letter, this means the upper-case letter
519is required at this position. The same word with a lower-case letter at this
520position will not match. When some of the other letters are upper-case it will
521not match either.
522
Bram Moolenaard042c562005-06-30 22:04:15 +0000523The word with all upper-case characters will always be OK.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000524
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
530
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000531The KEP affix ID can be used to specifically match a word with identical case
Bram Moolenaare7566042005-06-17 22:00:15 +0000532only, see below |spell-affix-KEP|.
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000533
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000534Note in line 5 to 7 that non-word characters are used. You can include
535any character in a word. When checking the text a word still only matches
536when it appears with a non-word character before and after it. For Myspell a
537word starting with a non-word character probably won't work.
538
539After the word there is an optional slash and flags. Most of these flags are
Bram Moolenaard042c562005-06-30 22:04:15 +0000540letters that indicate the affixes that can be used with this word. These are
541specified with SFX and PFX lines in the .aff file. See the Myspell
542documentation.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000543
544 *spell-affix-vim*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000545A flag that Vim adds and is not in Myspell is the flag defined with KEP in the
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000546affix file. This has the meaning that case matters. This can be used if the
547word does not have the first letter in upper case at the start of a sentence.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000548Example (assuming that = was used for KEP):
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000549
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
553
554 *spell-affix-mbyte*
555The basic word list is normally in an 8-bit encoding, which is mentioned in
556the affix file. The affix file must always be in the same encoding as the
557word list. This is compatible with Myspell. For Vim the encoding may also be
558something else, any encoding that "iconv" supports. The "SET" line must
559specify the name of the encoding. When using a multi-byte encoding it's
Bram Moolenaard042c562005-06-30 22:04:15 +0000560possible to use more different affixes (but Myspell doesn't support that, thus
561you may not want to use it anyway).
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000562
Bram Moolenaare13305e2005-06-19 22:54:15 +0000563
564CHARACTER TABLES
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000565 *spell-affix-chars*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000566When using an 8-bit encoding the affix file should define what characters are
567word 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()
569won't work. For example when using "cp1250" on Unix.
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000570
Bram Moolenaare7566042005-06-17 22:00:15 +0000571 *E761* *E762* *spell-affix-FOL*
572 *spell-affix-LOW* *spell-affix-UPP*
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000573Three lines in the affix file are needed. Simplistic example:
574
Bram Moolenaare13305e2005-06-19 22:54:15 +0000575 FOL áëñ ~
576 LOW áëñ ~
577 UPP ÁËÑ ~
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000578
579All three lines must have exactly the same number of characters.
580
581The "FOL" line specifies the case-folded characters. These are used to
582compare words while ignoring case. For most encodings this is identical to
583the lower case line.
584
585The "LOW" line specifies the characters in lower-case. Mostly it's equal to
586the "FOL" line.
587
588The "UPP" line specifies the characters with upper-case. That is, a character
589is upper-case where it's different from the character at the same position in
590"FOL".
591
592ASCII characters should be omitted, Vim always handles these in the same way.
593When the encoding is UTF-8 no word characters need to be specified.
594
595 *E763*
Bram Moolenaar3b506942005-06-23 22:36:45 +0000596Vim allows you to use spell checking for several languages in the same file.
597You can list them in the 'spelllang' option. As a consequence all spell files
598for the same encoding must use the same word characters, otherwise they can't
599be combined without errors. If you get a warning that the word tables differ
600you may need to generate the .spl file again with |:mkspell|. Check the FOL,
601LOW and UPP lines in the used .aff file.
602
603The XX.ascii.spl spell file generated with the "-ascii" argument will not
604contain the table with characters, so that it can be combine with spell files
605for any encoding. The .add.spl files also do not contain the table.
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000606
Bram Moolenaare7566042005-06-17 22:00:15 +0000607
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000608MID-WORD CHARACTERS
609 *spell-midword*
610Some characters are only to be considered word characters if they are used in
611between two ordinary word characters. An example is the single quote: It is
612often used to put text in quotes, thus it can't be recognized as a word
613character, but when it appears in between word characters it must be part of
614the word. This is needed to detect a spelling error such as they'are. That
615should be they're, but since "they" and "are" are words themselves that would
616go unnoticed.
617
618These characters are defined with MIDWORD in the .aff file:
619
620 MIDWORD '- ~
621
622
Bram Moolenaare13305e2005-06-19 22:54:15 +0000623AFFIXES
624 *spell-affix-PFX* *spell-affix-SFX*
625The usual PFX (prefix) and SFX (suffix) lines are supported (see the Myspell
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000626documentation or the Aspell manual:
627http://aspell.net/man-html/Affix-Compression.html).
Bram Moolenaare13305e2005-06-19 22:54:15 +0000628
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000629Note that Myspell ignores any extra text after the relevant info. Vim
630requires this text to start with a "#" so that mistakes don't go unnoticed.
631Example:
632
633 SFX F 0 in [^i]n # Spion > Spionin ~
634 SFX F 0 nen in # Bauerin > Bauerinnen ~
635
636An extra item for Vim is the "rare" flag. It must come after the other
637fields, before a comment. When used then all words that use the affix will be
638marked as rare words. Example:
639
640 PFX F 0 nene . rare ~
641 SFX F 0 oin n rare # hardly ever used ~
642
643However, if the word also appears as a good word in another way it won't be
644marked as rare.
Bram Moolenaare13305e2005-06-19 22:54:15 +0000645
646 *spell-affix-PFXPOSTPONE*
647When an affix file has very many prefixes that apply to many words it's not
648possible to build the whole word list in memory. This applies to Hebrew (a
649list with all words is over a Gbyte). In that case applying prefixes must be
650postponed. This makes spell checking slower. It is indicated by this keyword
651in the .aff file:
652
653 PFXPOSTPONE ~
654
655Only prefixes without a chop string can be postponed, prefixes with a chop
656string will still be included in the word list.
657
658
659KEEP-CASE WORDS
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000660 *spell-affix-KEP*
661In the affix file a KEP line can be used to define the affix name used for
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000662keep-case words. Example:
663
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000664 KEP = ~
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000665
666See above for an example |spell-affix-vim|.
667
Bram Moolenaare13305e2005-06-19 22:54:15 +0000668
669RARE WORDS
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000670 *spell-affix-RAR*
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000671In the affix file a RAR line can be used to define the affix name used for
672rare words. Example:
673
674 RAR ? ~
675
676Rare words are highlighted differently from bad words. This is to be used for
677words that are correct for the language, but are hardly ever used and could be
Bram Moolenaar30abd282005-06-22 22:35:10 +0000678a typing mistake anyway. When the same word is found as good it won't be
679highlighted as rare.
680
681
682BAD WORDS
683 *spell-affix-BAD*
684In the affix file a BAD line can be used to define the affix name used for
685bad words. Example:
686
687 BAD ! ~
688
689This can be used to exclude words that would otherwise be good. For example
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000690"the the" in the .dic file:
691
692 the the/! ~
693
694Once a word has been marked as bad it won't be undone by encountering the same
695word as good.
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000696
697
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000698REPLACEMENTS *spell-affix-REP*
699
700In the affix file REP items can be used to define common mistakes. This is
701used 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
710The first line specifies the number of REP lines following. Vim ignores it.
Bram Moolenaard042c562005-06-30 22:04:15 +0000711Don't include simple one-character replacements or swaps. Vim will try these
712anyway. You can include whole words if you want to, but you might want to use
713the "file:" item in 'spellsuggest' instead.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000714
715
716SIMILAR CHARACTERS *spell-affix-MAP*
717
Bram Moolenaard042c562005-06-30 22:04:15 +0000718In the affix file MAP items can be used to define letters that are very much
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000719alike. This is mostly used for a letter with different accents. This is used
720to prefer suggestions with these letters substituted. Example:
721
722 MAP 2 ~
723 MAP eéëêè ~
724 MAP uüùúû ~
725
726The first line specifies the number of MAP lines following. Vim ignores it.
727
Bram Moolenaard042c562005-06-30 22:04:15 +0000728Each letter must appear in only one of the MAP items. It's a bit more
729efficient if the first letter is ASCII or at least one without accents.
Bram Moolenaare7566042005-06-17 22:00:15 +0000730
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000731
Bram Moolenaard042c562005-06-30 22:04:15 +0000732SOUND-A-LIKE *spell-affix-SAL*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000733
734In the affix file SAL items can be used to define the sounds-a-like mechanism
735to be used. The main items define the "from" text and the "to" replacement.
Bram Moolenaard042c562005-06-30 22:04:15 +0000736Simplistic example:
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000737
738 SAL CIA X ~
739 SAL CH X ~
740 SAL C K ~
741 SAL K K ~
742
Bram Moolenaard042c562005-06-30 22:04:15 +0000743There are a few rules and this can become quite complicated. An explantion
744how it works can be found in the Aspell manual:
Bram Moolenaar42eeac32005-06-29 22:40:58 +0000745http://aspell.net/man-html/Phonetic-Code.html.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000746
747There 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
Bram Moolenaar42eeac32005-06-29 22:40:58 +0000755
756SIMPLE SOUNDFOLDING *spell-affix-SOFOFROM* *spell-affix-SOFOTO*
757
758The SAL mechanism is complex and slow. A simpler mechanism is mapping all
759characters to another character, mapping similar sounding characters to the
760same character. At the same time this does case folding. You can not have
Bram Moolenaard042c562005-06-30 22:04:15 +0000761both SAL items and simple soundfolding.
Bram Moolenaar42eeac32005-06-29 22:40:58 +0000762
763There are two items required: one to speficy the characters that are mapped
764and one that specifies the characters they are mapped to. They must have
765exactly the same number of characters. Example:
766
767 SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~
768 SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkes ~
769
770In the example all vowels are mapped to the same character 'e'. Another
Bram Moolenaard042c562005-06-30 22:04:15 +0000771method would be to leave out all vowels. Some characters that sound nearly
772the same and are often mixed up, such as 'm' and 'n', are mapped to the same
773character. Don't do this too much, all words will start looking alike.
Bram Moolenaar42eeac32005-06-29 22:40:58 +0000774
775Characters that do not appear in SOFOFROM will be left out, except that all
776white space is replaced by one space. Sequences of the same character in
777SOFOFROM are replaced by one.
778
779You 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
Bram Moolenaar217ad922005-03-20 22:37:15 +0000783 vim:tw=78:sw=4:ts=8:ft=help:norl: