blob: 68ecb0ebe0e69d4d6d4ca3a929bf529999ecc591 [file] [log] [blame]
Bram Moolenaar87b5ca52006-03-04 21:55:31 +00001*spell.txt* For Vim version 7.0aa. Last change: 2006 Mar 04
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|
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +000030 SpellCap word not capitalised |hl-SpellCap|
Bram Moolenaar520470a2005-06-16 21:59:56 +000031 SpellRare rare word |hl-SpellRare|
32 SpellLocal wrong spelling for selected region |hl-SpellLocal|
Bram Moolenaar217ad922005-03-20 22:37:15 +000033
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +000034Vim only checks words for spelling, there is no grammar check.
35
Bram Moolenaar45360022005-07-21 21:08:21 +000036If the 'mousemodel' option is set to "popup" and the cursor is on a badly
37spelled word or it is "popup_setpos" and the mouse pointer is on a badly
Bram Moolenaar16d8f872005-11-26 23:46:11 +000038spelled word, then the popup menu will contain a submenu to replace the bad
Bram Moolenaar45360022005-07-21 21:08:21 +000039word. Note: this slows down the appearance of the popup menu.
40
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +000041To search for the next misspelled word:
42
43 *]s* *E756*
44]s Move to next misspelled word after the cursor.
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +000045 A count before the command can be used to repeat.
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000046 'wrapscan' applies.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +000047
48 *[s*
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +000049[s Like "]s" but search backwards, find the misspelled
Bram Moolenaar30abd282005-06-22 22:35:10 +000050 word before the cursor. Doesn't recognize words
51 split over two lines, thus may stop at words that are
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000052 not highlighted as bad. Does not stop at word with
53 missing capital at the start of a line.
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +000054
55 *]S*
56]S Like "]s" but only stop at bad words, not at rare
57 words or words for another region.
58
59 *[S*
60[S Like "]S" but search backwards.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +000061
Bram Moolenaar217ad922005-03-20 22:37:15 +000062
Bram Moolenaarf75a9632005-09-13 21:20:47 +000063To add words to your own word list:
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000064
65 *zg*
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000066zg Add word under the cursor as a good word to the first
Bram Moolenaarda2303d2005-08-30 21:55:26 +000067 name in 'spellfile'. A count may precede the command
68 to indicate the entry in 'spellfile' to be used. A
69 count of two uses the second entry.
70
71 In Visual mode the selected characters are added as a
72 word (including white space!).
73 When the cursor is on text that is marked as badly
74 spelled then the marked text is used.
75 Otherwise the word under the cursor, separated by
76 non-word characters, is used.
77
78 If the word is explicitly marked as bad word in
79 another spell file the result is unpredictable.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000080
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000081 *zG*
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000082zG Like "zg" but add the word to the internal word list
83 |internal-wordlist|.
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000084
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000085 *zw*
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000086zw Like "zg" but mark the word as a wrong (bad) word.
Bram Moolenaar87b5ca52006-03-04 21:55:31 +000087 If the word already appears in 'spellfile' it is
88 turned into a comment line. See |spellfile-cleanup|
89 for getting rid of those.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000090
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000091 *zW*
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000092zW Like "zw" but add the word to the internal word list
93 |internal-wordlist|.
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000094
Bram Moolenaar87b5ca52006-03-04 21:55:31 +000095zuw *zug* *zuw*
96zug Undo |zw| and |zg|, remove the word from the entry in
97 'spellfile'. Count used as with |zg|.
98
99zuW *zuG* *zuW*
100zuG Undo |zW| and |zG|, remove the word from the internal
101 word list. Count used as with |zg|.
102
Bram Moolenaar520470a2005-06-16 21:59:56 +0000103 *:spe* *:spellgood*
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000104:[count]spe[llgood] {word}
Bram Moolenaar53180ce2005-07-05 21:48:14 +0000105 Add {word} as a good word to 'spellfile', like with
Bram Moolenaar87b5ca52006-03-04 21:55:31 +0000106 |zg|. Without count the first name is used, with a
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000107 count of two the second entry, etc.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000108
Bram Moolenaar53180ce2005-07-05 21:48:14 +0000109:spe[llgood]! {word} Add {word} as a good word to the internal word list,
Bram Moolenaar87b5ca52006-03-04 21:55:31 +0000110 like with |zG|.
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000111
Bram Moolenaar520470a2005-06-16 21:59:56 +0000112 *:spellw* *:spellwrong*
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000113:[count]spellw[rong] {word}
Bram Moolenaar53180ce2005-07-05 21:48:14 +0000114 Add {word} as a wrong (bad) word to 'spellfile', as
Bram Moolenaar87b5ca52006-03-04 21:55:31 +0000115 with |zw|. Without count the first name is used, with
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000116 a count of two the second entry, etc.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000117
Bram Moolenaar53180ce2005-07-05 21:48:14 +0000118:spellw[rong]! {word} Add {word} as a wrong (bad) word to the internal word
Bram Moolenaar87b5ca52006-03-04 21:55:31 +0000119 list, like with |zW|.
120
121:[count]spellu[ndo] {word} *:spellu* *:spellundo*
122 Like |zuw|. [count] used as with |:spellgood|.
123
124:spellu[ndo]! {word} Like |zuW|. [count] used as with |:spellgood|.
125
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000126
Bram Moolenaarf461c8e2005-06-25 23:04:51 +0000127After adding a word to 'spellfile' with the above commands its associated
Bram Moolenaard042c562005-06-30 22:04:15 +0000128".spl" file will automatically be updated and reloaded. If you change
129'spellfile' manually you need to use the |:mkspell| command. This sequence of
130commands mostly works well: >
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000131 :edit <file in 'spellfile'>
Bram Moolenaarf461c8e2005-06-25 23:04:51 +0000132< (make changes to the spell file) >
133 :mkspell! %
134
135More details about the 'spellfile' format below |spell-wordlist-format|.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000136
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000137 *internal-wordlist*
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000138The internal word list is used for all buffers where 'spell' is set. It is
139not stored, it is lost when you exit Vim. It is also cleared when 'encoding'
140is set.
141
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000142
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000143Finding suggestions for bad words:
Bram Moolenaarcc016f52005-12-10 20:23:46 +0000144 *z=*
145z= For the word under/after the cursor suggest correctly
Bram Moolenaard042c562005-06-30 22:04:15 +0000146 spelled words. This also works to find alternatives
147 for a word that is not highlighted as a bad word,
148 e.g., when the word after it is bad.
Bram Moolenaar7df351e2006-01-23 22:30:28 +0000149 In Visual mode the highlighted text is taken as the
150 word to be replaced.
151 The results are sorted on similarity to the word being
152 replaced.
Bram Moolenaar90915b52005-08-21 22:17:52 +0000153 This may take a long time. Hit CTRL-C when you get
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000154 bored.
Bram Moolenaar90915b52005-08-21 22:17:52 +0000155
156 If the command is used without a count the
157 alternatives are listed and you can enter the number
158 of your choice or press <Enter> if you don't want to
159 replace. You can also use the mouse to click on your
160 choice (only works if the mouse can be used in Normal
161 mode and when there are no line wraps). Click on the
162 first line (the header) to cancel.
163
164 If a count is used that suggestion is used, without
Bram Moolenaarcc016f52005-12-10 20:23:46 +0000165 prompting. For example, "1z=" always takes the first
Bram Moolenaar90915b52005-08-21 22:17:52 +0000166 suggestion.
167
168 If 'verbose' is non-zero a score will be displayed
169 with the suggestions to indicate the likeliness to the
170 badly spelled word (the higher the score the more
171 different).
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000172 When a word was replaced the redo command "." will
173 repeat the word replacement. This works like "ciw",
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000174 the good word and <Esc>. This does NOT work for Thai
175 and other languages without spaces between words.
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000176
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +0000177 *:spellr* *:spellrepall* *E752* *E753*
Bram Moolenaarcc016f52005-12-10 20:23:46 +0000178:spellr[epall] Repeat the replacement done by |z=| for all matches
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +0000179 with the replaced word in the current window.
180
Bram Moolenaar488c6512005-08-11 20:09:58 +0000181In Insert mode, when the cursor is after a badly spelled word, you can use
182CTRL-X s to find suggestions. This works like Insert mode completion. Use
183CTRL-N to use the next suggestion, CTRL-P to go back. |i_CTRL-X_s|
184
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000185The 'spellsuggest' option influences how the list of suggestions is generated
186and sorted. See |'spellsuggest'|.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000187
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000188The 'spellcapcheck' option is used to check the first word of a sentence
189starts with a capital. This doesn't work for the first word in the file.
190When there is a line break right after a sentence the highlighting of the next
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +0000191line may be postponed. Use |CTRL-L| when needed. Also see |set-spc-auto| for
192how it can be set automatically when 'spelllang' is set.
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000193
Bram Moolenaar4770d092006-01-12 23:22:24 +0000194Vim counts the number of times a good word is encountered. This is used to
195sort the suggestions: words that have been seen before get a small bonus,
196words that have been seen often get a bigger bonus. The COMMON item in the
197affix file can be used to define common words, so that this mechanism also
198works in a new or short file |spell-COMMON|.
199
Bram Moolenaard042c562005-06-30 22:04:15 +0000200==============================================================================
2012. Remarks on spell checking *spell-remarks*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000202
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000203PERFORMANCE
204
Bram Moolenaard042c562005-06-30 22:04:15 +0000205Vim does on-the-fly spell checking. To make this work fast the word list is
206loaded in memory. Thus this uses a lot of memory (1 Mbyte or more). There
207might also be a noticeable delay when the word list is loaded, which happens
208when 'spell' is set and when 'spelllang' is set while 'spell' was already set.
209To minimize the delay each word list is only loaded once, it is not deleted
210when 'spelllang' is made empty or 'spell' is reset. When 'encoding' is set
211all the word lists are reloaded, thus you may notice a delay then too.
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000212
213
Bram Moolenaar217ad922005-03-20 22:37:15 +0000214REGIONS
215
216A word may be spelled differently in various regions. For example, English
217comes in (at least) these variants:
218
219 en all regions
Bram Moolenaar5c5474b2005-04-19 21:40:26 +0000220 en_au Australia
Bram Moolenaar217ad922005-03-20 22:37:15 +0000221 en_ca Canada
Bram Moolenaar5c5474b2005-04-19 21:40:26 +0000222 en_gb Great Britain
223 en_nz New Zealand
224 en_us USA
Bram Moolenaar217ad922005-03-20 22:37:15 +0000225
226Words that are not used in one region but are used in another region are
Bram Moolenaar520470a2005-06-16 21:59:56 +0000227highlighted with SpellLocal |hl-SpellLocal|.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000228
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000229Always use lowercase letters for the language and region names.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000230
Bram Moolenaar3638c682005-06-08 22:05:14 +0000231When adding a word with |zg| or another command it's always added for all
232regions. You can change that by manually editing the 'spellfile'. See
Bram Moolenaar0dc065e2005-07-04 22:49:24 +0000233|spell-wordlist-format|. Note that the regions as specified in the files in
Bram Moolenaar16d8f872005-11-26 23:46:11 +0000234'spellfile' are only used when all entries in 'spelllang' specify the same
Bram Moolenaar0dc065e2005-07-04 22:49:24 +0000235region (not counting files specified by their .spl name).
Bram Moolenaar3638c682005-06-08 22:05:14 +0000236
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000237 *spell-german*
Bram Moolenaarae5bce12005-08-15 21:41:48 +0000238Specific exception: For German these special regions are used:
239 de all German words accepted
240 de_de old and new spelling
241 de_19 old spelling
242 de_20 new spelling
243 de_at Austria
244 de_ch Switzerland
245
Bram Moolenaar92d640f2005-09-05 22:11:52 +0000246 *spell-russian*
247Specific exception: For Russian these special regions are used:
248 ru all Russian words accepted
249 ru_ru "IE" letter spelling
250 ru_yo "YO" letter spelling
251
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000252 *spell-yiddish*
253Yiddish requires using "utf-8" encoding, because of the special characters
254used. If you are using latin1 Vim will use transliterated (romanized) Yiddish
255instead. If you want to use transliterated Yiddish with utf-8 use "yi-tr".
256In a table:
257 'encoding' 'spelllang'
258 utf-8 yi Yiddish
259 latin1 yi transliterated Yiddish
260 utf-8 yi-tr transliterated Yiddish
261
Bram Moolenaar217ad922005-03-20 22:37:15 +0000262
Bram Moolenaar3b506942005-06-23 22:36:45 +0000263SPELL FILES *spell-load*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000264
265Vim searches for spell files in the "spell" subdirectory of the directories in
Bram Moolenaar3638c682005-06-08 22:05:14 +0000266'runtimepath'. The name is: LL.EEE.spl, where:
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000267 LL the language name
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000268 EEE the value of 'encoding'
Bram Moolenaar217ad922005-03-20 22:37:15 +0000269
Bram Moolenaar3b506942005-06-23 22:36:45 +0000270The value for "LL" comes from 'spelllang', but excludes the region name.
271Examples:
272 'spelllang' LL ~
273 en_us en
274 en-rare en-rare
275 medical_ca medical
276
Bram Moolenaar3638c682005-06-08 22:05:14 +0000277Only the first file is loaded, the one that is first in 'runtimepath'. If
278this succeeds then additionally files with the name LL.EEE.add.spl are loaded.
279All the ones that are found are used.
280
Bram Moolenaar1ef15e32006-02-01 21:56:25 +0000281If no spell file is found the |SpellFileMissing| autocommand event is
282triggered. This may trigger the |spellfile.vim| plugin to offer you
283downloading the spell file.
284
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000285Additionally, the files related to the names in 'spellfile' are loaded. These
286are the files that |zg| and |zw| add good and wrong words to.
Bram Moolenaar3b506942005-06-23 22:36:45 +0000287
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000288Exceptions:
289- Vim uses "latin1" when 'encoding' is "iso-8859-15". The euro sign doesn't
290 matter for spelling.
291- When no spell file for 'encoding' is found "ascii" is tried. This only
292 works for languages where nearly all words are ASCII, such as English. It
293 helps when 'encoding' is not "latin1", such as iso-8859-2, and English text
Bram Moolenaar3638c682005-06-08 22:05:14 +0000294 is being edited. For the ".add" files the same name as the found main
295 spell file is used.
296
297For example, with these values:
298 'runtimepath' is "~/.vim,/usr/share/vim70,~/.vim/after"
299 'encoding' is "iso-8859-2"
300 'spelllang' is "pl"
301
302Vim will look for:
3031. ~/.vim/spell/pl.iso-8859-2.spl
3042. /usr/share/vim70/spell/pl.iso-8859-2.spl
3053. ~/.vim/spell/pl.iso-8859-2.add.spl
3064. /usr/share/vim70/spell/pl.iso-8859-2.add.spl
3075. ~/.vim/after/spell/pl.iso-8859-2.add.spl
308
309This assumes 1. is not found and 2. is found.
310
311If 'encoding' is "latin1" Vim will look for:
3121. ~/.vim/spell/pl.latin1.spl
3132. /usr/share/vim70/spell/pl.latin1.spl
3143. ~/.vim/after/spell/pl.latin1.spl
3154. ~/.vim/spell/pl.ascii.spl
3165. /usr/share/vim70/spell/pl.ascii.spl
3176. ~/.vim/after/spell/pl.ascii.spl
318
319This assumes none of them are found (Polish doesn't make sense when leaving
320out the non-ASCII characters).
Bram Moolenaar217ad922005-03-20 22:37:15 +0000321
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000322Spelling for EBCDIC is currently not supported.
323
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000324A spell file might not be available in the current 'encoding'. See
325|spell-mkspell| about how to create a spell file. Converting a spell file
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000326with "iconv" will NOT work!
Bram Moolenaar217ad922005-03-20 22:37:15 +0000327
Bram Moolenaara40ceaf2006-01-13 22:35:40 +0000328 *spell-sug-file* *E781*
Bram Moolenaar4770d092006-01-12 23:22:24 +0000329If there is a file with exactly the same name as the ".spl" file but ending in
330".sug", that file will be used for giving better suggestions. It isn't loaded
331before suggestions are made to reduce memory use.
332
Bram Moolenaara40ceaf2006-01-13 22:35:40 +0000333 *E758* *E759* *E778* *E779* *E780* *E782*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000334When loading a spell file Vim checks that it is properly formatted. If you
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000335get an error the file may be truncated, modified or intended for another Vim
336version.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000337
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000338
Bram Moolenaar87b5ca52006-03-04 21:55:31 +0000339SPELLFILE CLEANUP *spellfile-cleanup*
340
341The |zw| command turns existing entries in 'spellfile' into comment lines.
342This avoids having to write a new file every time, but results in the file
343only getting longer, never shorter. To clean up the comment lines in all
344".add" spell files do this: >
345 :runtime spell/cleanadd.vim
346
347This deletes all comment lines, except the ones that start with "##". Use
348"##" lines to add comments that you want to keep.
349
350You can invoke this script as often as you like. A variable is provided to
351skip updating files that have been changed recently. Set it to the number of
352seconds that has passed since a file was changed before it will be cleaned.
353For example, to clean only files that were not changed in the last hour: >
354 let g:spell_clean_limit = 60 * 60
355The default is one second.
356
357
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000358WORDS
359
360Vim uses a fixed method to recognize a word. This is independent of
361'iskeyword', so that it also works in help files and for languages that
362include characters like '-' in 'iskeyword'. The word characters do depend on
363'encoding'.
364
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000365The table with word characters is stored in the main .spl file. Therefore it
366matters what the current locale is when generating it! A .add.spl file does
Bram Moolenaarf461c8e2005-06-25 23:04:51 +0000367not contain a word table though.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000368
Bram Moolenaar3638c682005-06-08 22:05:14 +0000369A word that starts with a digit is always ignored. That includes hex numbers
370in the form 0xff and 0XFF.
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000371
372
Bram Moolenaar30abd282005-06-22 22:35:10 +0000373WORD COMBINATIONS
374
375It is possible to spell-check words that include a space. This is used to
376recognize words that are invalid when used by themselves, e.g. for "et al.".
377It can also be used to recognize "the the" and highlight it.
378
379The number of spaces is irrelevant. In most cases a line break may also
380appear. However, this makes it difficult to find out where to start checking
381for spelling mistakes. When you make a change to one line and only that line
382is redrawn Vim won't look in the previous line, thus when "et" is at the end
383of the previous line "al." will be flagged as an error. And when you type
384"the<CR>the" the highlighting doesn't appear until the first line is redrawn.
385Use |CTRL-L| to redraw right away. "[s" will also stop at a word combination
386with a line break.
387
388When encountering a line break Vim skips characters such as '*', '>' and '"',
389so that comments in C, shell and Vim code can be spell checked.
390
391
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +0000392SYNTAX HIGHLIGHTING *spell-syntax*
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000393
394Files that use syntax highlighting can specify where spell checking should be
395done:
396
Bram Moolenaar3638c682005-06-08 22:05:14 +00003971. everywhere default
3982. in specific items use "contains=@Spell"
3993. everywhere but specific items use "contains=@NoSpell"
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000400
Bram Moolenaar3638c682005-06-08 22:05:14 +0000401For the second method adding the @NoSpell cluster will disable spell checking
402again. This can be used, for example, to add @Spell to the comments of a
403program, and add @NoSpell for items that shouldn't be checked.
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000404
Bram Moolenaar30abd282005-06-22 22:35:10 +0000405
406VIM SCRIPTS
407
408If you want to write a Vim script that does something with spelling, you may
409find these functions useful:
410
411 spellbadword() find badly spelled word at the cursor
412 spellsuggest() get list of spelling suggestions
Bram Moolenaard042c562005-06-30 22:04:15 +0000413 soundfold() get the sound-a-like version of a word
Bram Moolenaar30abd282005-06-22 22:35:10 +0000414
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +0000415
416SETTING 'spellcapcheck' AUTOMATICALLY *set-spc-auto*
417
418After the 'spelllang' option has been set successfully, Vim will source the
419files "spell/LANG.vim" in 'runtimepath'. "LANG" is the value of 'spelllang'
420up to the first comma, dot or underscore. This can be used to set options
421specifically for the language, especially 'spellcapcheck'.
422
423The distribution includes a few of these files. Use this command to see what
424they do: >
425 :next $VIMRUNTIME/spell/*.vim
426
427Note that the default scripts don't set 'spellcapcheck' if it was changed from
428the default value. This assumes the user prefers another value then.
429
Bram Moolenaarae5bce12005-08-15 21:41:48 +0000430
431DOUBLE SCORING *spell-double-scoring*
432
433The 'spellsuggest' option can be used to select "double" scoring. This
434mechanism is based on the principle that there are two kinds of spelling
435mistakes:
436
4371. You know how to spell the word, but mistype something. This results in a
438 small editing distance (character swapped/omitted/inserted) and possibly a
439 word that sounds completely different.
440
4412. You don't know how to spell the word and type something that sounds right.
442 The edit distance can be big but the word is similar after sound-folding.
443
444Since scores for these two mistakes will be very different we use a list
445for each and mix them.
446
447The sound-folding is slow and people that know the language won't make the
448second kind of mistakes. Therefore 'spellsuggest' can be set to select the
449preferred method for scoring the suggestions.
450
Bram Moolenaar217ad922005-03-20 22:37:15 +0000451==============================================================================
Bram Moolenaard042c562005-06-30 22:04:15 +00004523. Generating a spell file *spell-mkspell*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000453
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000454Vim uses a binary file format for spelling. This greatly speeds up loading
455the word list and keeps it small.
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000456 *.aff* *.dic* *Myspell*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000457You can create a Vim spell file from the .aff and .dic files that Myspell
458uses. Myspell is used by OpenOffice.org and Mozilla. You should be able to
459find them here:
460 http://lingucomponent.openoffice.org/spell_dic.html
Bram Moolenaar30abd282005-06-22 22:35:10 +0000461You can also use a plain word list. The results are the same, the choice
Bram Moolenaard042c562005-06-30 22:04:15 +0000462depends on what word lists you can find.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000463
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +0000464If you install Aap (from www.a-a-p.org) you can use the recipes in the
465runtime/spell/??/ directories. Aap will take care of downloading the files,
466apply patches needed for Vim and build the .spl file.
467
Bram Moolenaare13305e2005-06-19 22:54:15 +0000468Make sure your current locale is set properly, otherwise Vim doesn't know what
469characters are upper/lower case letters. If the locale isn't available (e.g.,
470when using an MS-Windows codepage on Unix) add tables to the .aff file
Bram Moolenaar3b506942005-06-23 22:36:45 +0000471|spell-affix-chars|. If the .aff file doesn't define a table then the word
472table of the currently active spelling is used. If spelling is not active
473then Vim will try to guess.
Bram Moolenaare13305e2005-06-19 22:54:15 +0000474
Bram Moolenaar3b506942005-06-23 22:36:45 +0000475 *:mksp* *:mkspell*
476:mksp[ell][!] [-ascii] {outname} {inname} ...
Bram Moolenaar16d8f872005-11-26 23:46:11 +0000477 Generate a Vim spell file from word lists. Example: >
Bram Moolenaard042c562005-06-30 22:04:15 +0000478 :mkspell /tmp/nl nl_NL.words
Bram Moolenaar3b506942005-06-23 22:36:45 +0000479< *E751*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000480 When {outname} ends in ".spl" it is used as the output
481 file name. Otherwise it should be a language name,
Bram Moolenaar3b506942005-06-23 22:36:45 +0000482 such as "en", without the region name. The file
483 written will be "{outname}.{encoding}.spl", where
484 {encoding} is the value of the 'encoding' option.
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000485
Bram Moolenaard042c562005-06-30 22:04:15 +0000486 When the output file already exists [!] must be used
Bram Moolenaar520470a2005-06-16 21:59:56 +0000487 to overwrite it.
488
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000489 When the [-ascii] argument is present, words with
490 non-ascii characters are skipped. The resulting file
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000491 ends in "ascii.spl".
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000492
493 The input can be the Myspell format files {inname}.aff
494 and {inname}.dic. If {inname}.aff does not exist then
495 {inname} is used as the file name of a plain word
496 list.
497
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000498 Multiple {inname} arguments can be given to combine
499 regions into one Vim spell file. Example: >
500 :mkspell ~/.vim/spell/en /tmp/en_US /tmp/en_CA /tmp/en_AU
501< This combines the English word lists for US, CA and AU
502 into one en.spl file.
503 Up to eight regions can be combined. *E754* *755*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000504 The REP and SAL items of the first .aff file where
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000505 they appear are used. |spell-REP| |spell-SAL|
Bram Moolenaar217ad922005-03-20 22:37:15 +0000506
Bram Moolenaar30abd282005-06-22 22:35:10 +0000507 This command uses a lot of memory, required to find
Bram Moolenaar8aff23a2005-08-19 20:40:30 +0000508 the optimal word tree (Polish, Italian and Hungarian
509 require several hundred Mbyte). The final result will
510 be much smaller, because compression is used. To
511 avoid running out of memory compression will be done
512 now and then. This can be tuned with the 'mkspellmem'
513 option.
Bram Moolenaar30abd282005-06-22 22:35:10 +0000514
Bram Moolenaard042c562005-06-30 22:04:15 +0000515 After the spell file was written and it was being used
516 in a buffer it will be reloaded automatically.
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000517
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000518:mksp[ell] [-ascii] {name}.{enc}.add
519 Like ":mkspell" above, using {name}.{enc}.add as the
Bram Moolenaard042c562005-06-30 22:04:15 +0000520 input file and producing an output file in the same
521 directory that has ".spl" appended.
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000522
523:mksp[ell] [-ascii] {name}
524 Like ":mkspell" above, using {name} as the input file
Bram Moolenaard042c562005-06-30 22:04:15 +0000525 and producing an output file in the same directory
526 that has ".{enc}.spl" appended.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000527
Bram Moolenaarae5bce12005-08-15 21:41:48 +0000528Vim will report the number of duplicate words. This might be a mistake in the
529list of words. But sometimes it is used to have different prefixes and
530suffixes for the same basic word to avoid them combining (e.g. Czech uses
Bram Moolenaar8aff23a2005-08-19 20:40:30 +0000531this). If you want Vim to report all duplicate words set the 'verbose'
532option.
Bram Moolenaarae5bce12005-08-15 21:41:48 +0000533
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000534Since you might want to change a Myspell word list for use with Vim the
535following procedure is recommended:
Bram Moolenaar217ad922005-03-20 22:37:15 +0000536
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00005371. Obtain the xx_YY.aff and xx_YY.dic files from Myspell.
5382. Make a copy of these files to xx_YY.orig.aff and xx_YY.orig.dic.
5393. Change the xx_YY.aff and xx_YY.dic files to remove bad words, add missing
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000540 words, define word characters with FOL/LOW/UPP, etc. The distributed
541 "src/spell/*.diff" files can be used.
Bram Moolenaard042c562005-06-30 22:04:15 +00005424. Start Vim with the right locale and use |:mkspell| to generate the Vim
543 spell file.
5445. Try out the spell file with ":set spell spelllang=xx" if you wrote it in
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +0000545 a spell directory in 'runtimepath', or ":set spelllang=xx.enc.spl" if you
Bram Moolenaard042c562005-06-30 22:04:15 +0000546 wrote it somewhere else.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000547
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000548When the Myspell files are updated you can merge the differences:
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00005491. Obtain the new Myspell files as xx_YY.new.aff and xx_UU.new.dic.
5502. Use Vimdiff to see what changed: >
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000551 vimdiff xx_YY.orig.dic xx_YY.new.dic
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00005523. Take over the changes you like in xx_YY.dic.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000553 You may also need to change xx_YY.aff.
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00005544. 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 +0000555
Bram Moolenaar3b506942005-06-23 22:36:45 +0000556
Bram Moolenaar8aff23a2005-08-19 20:40:30 +0000557SPELL FILE VERSIONS *E770* *E771* *E772*
558
559Spell checking is a relatively new feature in Vim, thus it's possible that the
560.spl file format will be changed to support more languages. Vim will check
561the validity of the spell file and report anything wrong.
562
563 E771: Old spell file, needs to be updated ~
564This spell file is older than your Vim. You need to update the .spl file.
565
566 E772: Spell file is for newer version of Vim ~
567This means the spell file was made for a later version of Vim. You need to
568update Vim.
569
570 E770: Unsupported section in spell file ~
571This means the spell file was made for a later version of Vim and contains a
572section that is required for the spell file to work. In this case it's
573probably a good idea to upgrade your Vim.
574
575
Bram Moolenaar3b506942005-06-23 22:36:45 +0000576SPELL FILE DUMP
577
578If for some reason you want to check what words are supported by the currently
579used spelling files, use this command:
580
581 *:spelldump* *:spelld*
582:spelld[ump] Open a new window and fill it with all currently valid
Bram Moolenaarac6e65f2005-08-29 22:25:38 +0000583 words. Compound words are not included.
Bram Moolenaard042c562005-06-30 22:04:15 +0000584 Note: For some languages the result may be enormous,
585 causing Vim to run out of memory.
Bram Moolenaar3b506942005-06-23 22:36:45 +0000586
Bram Moolenaar4770d092006-01-12 23:22:24 +0000587:spelld[ump]! Like ":spelldump" and include the word count. This is
588 the number of times the word was found while
589 updating the screen. Words that are in COMMON items
590 get a starting count of 10.
591
Bram Moolenaar3b506942005-06-23 22:36:45 +0000592The format of the word list is used |spell-wordlist-format|. You should be
593able to read it with ":mkspell" to generate one .spl file that includes all
594the words.
595
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000596When all entries to 'spelllang' use the same regions or no regions at all then
597the region information is included in the dumped words. Otherwise only words
598for the current region are included and no "/regions" line is generated.
Bram Moolenaar3b506942005-06-23 22:36:45 +0000599
Bram Moolenaard042c562005-06-30 22:04:15 +0000600Comment lines with the name of the .spl file are used as a header above the
601words that were generated from that .spl file.
Bram Moolenaar3b506942005-06-23 22:36:45 +0000602
Bram Moolenaar1ef15e32006-02-01 21:56:25 +0000603
604SPELL FILE MISSING *spell-SpellFileMissing* *spellfile.vim*
605
606If the spell file for the language you are using is not available, you will
607get an error message. But if the "spellfile.vim" plugin is active it will
608offer you to download the spell file. Just follow the instructions, it will
609ask you where to write the file.
610
611The plugin has a default place where to look for spell files, on the Vim ftp
612server. If you want to use another location or another protocol, set the
613g:spellfile_URL variable to the directory that holds the spell files. The
614|netrw| plugin is used for getting the file, look there for the speficic
615syntax of the URL. Example: >
616 let g:spellfile_URL = 'http://ftp.vim.org/vim/runtime/spell'
617You may need to escape special characters.
618
619The plugin will only ask about downloading a language once. If you want to
620try again anyway restart Vim, or set g:spellfile_URL to another value (e.g.,
621prepend a space).
622
623To avoid using the "spellfile.vim" plugin do this in your vimrc file: >
624
625 let loaded_spellfile_plugin = 1
626
627Instead of using the plugin you can define a |SpellFileMissing| autocommand to
628handle the missing file yourself. You can use it like this: >
629
630 :au SpellFileMissing * call Download_spell_file(expand('<amatch>'))
631
632Thus the <amatch> item contains the name of the language. Another important
633value is 'encoding', since every encoding has its own spell file. With two
634exceptions:
635- For ISO-8859-15 (latin9) the name "latin1" is used (the encodings only
636 differ in characters not used in dictionary words).
637- The name "ascii" may also be used for some languages where the words use
638 only ASCII letters for most of the words.
639
640The default "spellfile.vim" plugin uses this autocommand, if you define your
641autocommand afterwars you may want to use ":au! SpellFileMissing" to overrule
642it. If you define your autocommand before the plugin is loaded it will notice
643this and not do anything.
644
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000645==============================================================================
Bram Moolenaard042c562005-06-30 22:04:15 +00006464. Spell file format *spell-file-format*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000647
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000648This is the format of the files that are used by the person who creates and
649maintains a word list.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000650
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000651Note that we avoid the word "dictionary" here. That is because the goal of
652spell checking differs from writing a dictionary (as in the book). For
Bram Moolenaar16d8f872005-11-26 23:46:11 +0000653spelling we need a list of words that are OK, thus should not be highlighted.
654Person and company names will not appear in a dictionary, but do appear in a
655word list. And some old words are rarely used while they are common
656misspellings. These do appear in a dictionary but not in a word list.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000657
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +0000658There are two formats: A straight list of words and a list using affix
Bram Moolenaard042c562005-06-30 22:04:15 +0000659compression. The files with affix compression are used by Myspell (Mozilla
660and OpenOffice.org). This requires two files, one with .aff and one with .dic
661extension.
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000662
663
Bram Moolenaard042c562005-06-30 22:04:15 +0000664FORMAT OF STRAIGHT WORD LIST *spell-wordlist-format*
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000665
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000666The words must appear one per line. That is all that is required.
Bram Moolenaard042c562005-06-30 22:04:15 +0000667
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000668Additionally the following items are recognized:
Bram Moolenaard042c562005-06-30 22:04:15 +0000669
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000670- Empty and blank lines are ignored.
Bram Moolenaard042c562005-06-30 22:04:15 +0000671
Bram Moolenaar4770d092006-01-12 23:22:24 +0000672 # comment ~
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000673- Lines starting with a # are ignored (comment lines).
Bram Moolenaard042c562005-06-30 22:04:15 +0000674
Bram Moolenaar4770d092006-01-12 23:22:24 +0000675 /encoding=utf-8 ~
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000676- A line starting with "/encoding=", before any word, specifies the encoding
677 of the file. After the second '=' comes an encoding name. This tells Vim
Bram Moolenaard042c562005-06-30 22:04:15 +0000678 to setup conversion from the specified encoding to 'encoding'. Thus you can
679 use one word list for several target encodings.
680
Bram Moolenaar4770d092006-01-12 23:22:24 +0000681 /regions=usca ~
Bram Moolenaar3638c682005-06-08 22:05:14 +0000682- A line starting with "/regions=" specifies the region names that are
683 supported. Each region name must be two ASCII letters. The first one is
684 region 1. Thus "/regions=usca" has region 1 "us" and region 2 "ca".
Bram Moolenaard042c562005-06-30 22:04:15 +0000685 In an addition word list the region names should be equal to the main word
686 list!
687
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000688- Other lines starting with '/' are reserved for future use. The ones that
Bram Moolenaar4770d092006-01-12 23:22:24 +0000689 are not recognized are ignored. You do get a warning message, so that you
690 know something won't work.
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000691
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000692- A "/" may follow the word with the following items:
693 = Case must match exactly.
694 ? Rare word.
695 ! Bad (wrong) word.
696 digit A region in which the word is valid. If no regions are
697 specified the word is valid in all regions.
698
Bram Moolenaar3638c682005-06-08 22:05:14 +0000699Example:
700
701 # This is an example word list comment
702 /encoding=latin1 encoding of the file
703 /regions=uscagb regions "us", "ca" and "gb"
704 example word for all regions
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000705 blah/12 word for regions "us" and "ca"
706 vim/! bad word
707 Campbell/?3 rare word in region 3 "gb"
708 's mornings/= keep-case word
Bram Moolenaar3638c682005-06-08 22:05:14 +0000709
Bram Moolenaar0dc065e2005-07-04 22:49:24 +0000710Note that when "/=" is used the same word with all upper-case letters is not
711accepted. This is different from a word with mixed case that is automatically
712marked as keep-case, those words may appear in all upper-case letters.
713
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000714
Bram Moolenaar4770d092006-01-12 23:22:24 +0000715FORMAT WITH .AFF and .DIC FILES
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000716
Bram Moolenaar4770d092006-01-12 23:22:24 +0000717There are two files: the basic word list and an affix file. The affix file
718specifies settings for the language and can contain affixes. The affixes are
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000719used to modify the basic words to get the full word list. This significantly
720reduces the number of words, especially for a language like Polish. This is
721called affix compression.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000722
Bram Moolenaar4770d092006-01-12 23:22:24 +0000723The basic word list and the affix file are combined with the ":mkspell"
724command and results in a binary spell file. All the preprocessing has been
725done, thus this file loads fast. The binary spell file format is described in
726the source code (src/spell.c). But only developers need to know about it.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000727
728The preprocessing also allows us to take the Myspell language files and modify
729them before the Vim word list is made. The tools for this can be found in the
730"src/spell" directory.
731
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000732The format for the affix and word list files is based on what Myspell uses
733(the spell checker of Mozilla and OpenOffice.org). A description can be found
734here:
735 http://lingucomponent.openoffice.org/affix.readme ~
736Note that affixes are case sensitive, this isn't obvious from the description.
737
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000738Vim supports quite a few extras. They are described below |spell-affix-vim|.
739Attempts have been made to keep this compatible with other spell checkers, so
Bram Moolenaar4770d092006-01-12 23:22:24 +0000740that the same files can often be used. One other project that offers more
741than Myspell is Hunspell ( http://hunspell.sf.net ).
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000742
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000743
Bram Moolenaar3638c682005-06-08 22:05:14 +0000744WORD LIST FORMAT *spell-dic-format*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000745
Bram Moolenaar4770d092006-01-12 23:22:24 +0000746A short example, with line numbers:
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000747
Bram Moolenaar4770d092006-01-12 23:22:24 +0000748 1 1234 ~
749 2 aan ~
750 3 Als ~
751 4 Etten-Leur ~
752 5 et al. ~
753 6 's-Gravenhage ~
754 7 's-Gravenhaags ~
755 8 # word that differs between regions ~
756 9 kado/1 ~
757 10 cadeau/2 ~
758 11 TCP,IP ~
759 12 /the S affix may add a 's' ~
760 13 bedel/S ~
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000761
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000762The first line contains the number of words. Vim ignores it, but you do get
763an error message if it's not there. *E760*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000764
Bram Moolenaar4770d092006-01-12 23:22:24 +0000765What follows is one word per line. White space at the end of the line is
766ignored, all other white space matters. The encoding is specified in the
767affix file |spell-SET|.
768
769Comment lines start with '#' or '/'. See the example lines 8 and 12. Note
770that putting a comment after a word is NOT allowed:
771
772 someword # comment that causes an error! ~
773
774After the word there is an optional slash and flags. Most of these flags are
775letters that indicate the affixes that can be used with this word. These are
776specified with SFX and PFX lines in the .aff file, see |spell-SFX| and
777|spell-PFX|. Vim allows using other flag types with the FLAG item in the
778affix file |spell-FLAG|.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000779
780When the word only has lower-case letters it will also match with the word
781starting with an upper-case letter.
782
783When the word includes an upper-case letter, this means the upper-case letter
784is required at this position. The same word with a lower-case letter at this
785position will not match. When some of the other letters are upper-case it will
786not match either.
787
Bram Moolenaar4770d092006-01-12 23:22:24 +0000788The word with all upper-case characters will always be OK,
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000789
790 word list matches does not match ~
791 als als Als ALS ALs AlS aLs aLS
792 Als Als ALS als ALs AlS aLs aLS
793 ALS ALS als Als ALs AlS aLs aLS
794 AlS AlS ALS als Als ALs aLs aLS
795
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +0000796The KEEPCASE affix ID can be used to specifically match a word with identical
797case only, see below |spell-KEEPCASE|.
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000798
Bram Moolenaar4770d092006-01-12 23:22:24 +0000799Note: in line 5 to 7 non-word characters are used. You can include any
800character in a word. When checking the text a word still only matches when it
801appears with a non-word character before and after it. For Myspell a word
802starting with a non-word character probably won't work.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000803
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000804In line 12 the word "TCP/IP" is defined. Since the slash has a special
805meaning the comma is used instead. This is defined with the SLASH item in the
Bram Moolenaar4770d092006-01-12 23:22:24 +0000806affix file, see |spell-SLASH|. Note that without this SLASH item the word
807will be "TCP,IP".
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000808
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000809
Bram Moolenaar4770d092006-01-12 23:22:24 +0000810AFFIX FILE FORMAT *spell-aff-format* *spell-affix-vim*
Bram Moolenaar0dc065e2005-07-04 22:49:24 +0000811
Bram Moolenaar4770d092006-01-12 23:22:24 +0000812 *spell-affix-comment*
813Comment lines in the .aff file start with a '#':
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000814
Bram Moolenaar4770d092006-01-12 23:22:24 +0000815 # comment line ~
816
817With some items it's also possible to put a comment after it, but this isn't
818supported in general.
819
820
821ENCODING *spell-SET*
822
823The affix file can be in any encoding that is supported by "iconv". However,
824in some cases the current locale should also be set properly at the time
825|:mkspell| is invoked. Adding FOL/LOW/UPP lines removes this requirement
826|spell-FOL|.
827
828The encoding should be specified before anything where the encoding matters.
829The encoding applies both to the affix file and the dictionary file. It is
830done with a SET line:
831
832 SET utf-8 ~
833
834The encoding can be different from the value of the 'encoding' option at the
835time ":mkspell" is used. Vim will then convert everything to 'encoding' and
836generate a spell file for 'encoding'. If some of the used characters to not
837fit in 'encoding' you will get an error message.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000838 *spell-affix-mbyte*
Bram Moolenaar4770d092006-01-12 23:22:24 +0000839When using a multi-byte encoding it's possible to use more different affix
840flags. But Myspell doesn't support that, thus you may not want to use it
841anyway. For compatibility use an 8-bit encoding.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000842
Bram Moolenaare13305e2005-06-19 22:54:15 +0000843
844CHARACTER TABLES
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000845 *spell-affix-chars*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000846When using an 8-bit encoding the affix file should define what characters are
Bram Moolenaar4770d092006-01-12 23:22:24 +0000847word characters. This is because the system where ":mkspell" is used may not
848support a locale with this encoding and isalpha() won't work. For example
849when using "cp1250" on Unix.
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000850 *E761* *E762* *spell-FOL*
851 *spell-LOW* *spell-UPP*
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000852Three lines in the affix file are needed. Simplistic example:
853
Bram Moolenaare13305e2005-06-19 22:54:15 +0000854 FOL áëñ ~
855 LOW áëñ ~
856 UPP ÁËÑ ~
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000857
858All three lines must have exactly the same number of characters.
859
860The "FOL" line specifies the case-folded characters. These are used to
861compare words while ignoring case. For most encodings this is identical to
862the lower case line.
863
864The "LOW" line specifies the characters in lower-case. Mostly it's equal to
865the "FOL" line.
866
867The "UPP" line specifies the characters with upper-case. That is, a character
868is upper-case where it's different from the character at the same position in
869"FOL".
870
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000871An exception is made for the German sharp s ß. The upper-case version is
872"SS". In the FOL/LOW/UPP lines it should be included, so that it's recognized
873as a word character, but use the ß character in all three.
874
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000875ASCII characters should be omitted, Vim always handles these in the same way.
876When the encoding is UTF-8 no word characters need to be specified.
877
878 *E763*
Bram Moolenaar3b506942005-06-23 22:36:45 +0000879Vim allows you to use spell checking for several languages in the same file.
880You can list them in the 'spelllang' option. As a consequence all spell files
881for the same encoding must use the same word characters, otherwise they can't
882be combined without errors. If you get a warning that the word tables differ
883you may need to generate the .spl file again with |:mkspell|. Check the FOL,
884LOW and UPP lines in the used .aff file.
885
886The XX.ascii.spl spell file generated with the "-ascii" argument will not
887contain the table with characters, so that it can be combine with spell files
888for any encoding. The .add.spl files also do not contain the table.
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000889
Bram Moolenaare7566042005-06-17 22:00:15 +0000890
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000891MID-WORD CHARACTERS
892 *spell-midword*
893Some characters are only to be considered word characters if they are used in
894between two ordinary word characters. An example is the single quote: It is
895often used to put text in quotes, thus it can't be recognized as a word
896character, but when it appears in between word characters it must be part of
897the word. This is needed to detect a spelling error such as they'are. That
898should be they're, but since "they" and "are" are words themselves that would
899go unnoticed.
900
Bram Moolenaar4770d092006-01-12 23:22:24 +0000901These characters are defined with MIDWORD in the .aff file. Example:
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000902
903 MIDWORD '- ~
904
905
Bram Moolenaar6e7c7f32005-08-24 22:16:11 +0000906FLAG TYPES *spell-FLAG*
907
908Flags are used to specify the affixes that can be used with a word and for
909other properties of the word. Normally single-character flags are used. This
910limits the number of possible flags, especially for 8-bit encodings. The FLAG
911item can be used if more affixes are to be used. Possible values:
912
913 FLAG long use two-character flags
914 FLAG num use numbers, from 1 up to 65000
Bram Moolenaar81f1ecb2005-08-25 21:27:31 +0000915 FLAG caplong use one-character flags without A-Z and two-character
Bram Moolenaar6e7c7f32005-08-24 22:16:11 +0000916 flags that start with A-Z
917
918With "FLAG num" the numbers in a list of affixes need to be separated with a
919comma: "234,2143,1435". This method is inefficient, but useful if the file is
920generated with a program.
921
Bram Moolenaar81f1ecb2005-08-25 21:27:31 +0000922When using "caplong" the two-character flags all start with a capital: "Aa",
923"B1", "BB", etc. This is useful to use one-character flags for the most
924common items and two-character flags for uncommon items.
Bram Moolenaar6e7c7f32005-08-24 22:16:11 +0000925
926Note: When using utf-8 only characters up to 65000 may be used for flags.
927
928
Bram Moolenaare13305e2005-06-19 22:54:15 +0000929AFFIXES
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000930 *spell-PFX* *spell-SFX*
Bram Moolenaare13305e2005-06-19 22:54:15 +0000931The usual PFX (prefix) and SFX (suffix) lines are supported (see the Myspell
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000932documentation or the Aspell manual:
933http://aspell.net/man-html/Affix-Compression.html).
Bram Moolenaare13305e2005-06-19 22:54:15 +0000934
Bram Moolenaar4770d092006-01-12 23:22:24 +0000935Summary:
936 SFX L Y 2 ~
937 SFX L 0 re [^x] ~
938 SFX L 0 ro x ~
939
940The first line is a header and has four fields:
941 SFX {flag} {combine} {count}
942
943{flag} The name used for the suffix. Mostly it's a single letter,
944 but other characters can be used, see |spell-FLAG|.
945
946{combine} Can be 'Y' or 'N'. When 'Y' then the word plus suffix can
947 also have a prefix. When 'N' then a prefix is not allowed.
948
949{count} The number of lines following. If this is wrong you will get
950 an error message.
951
952For PFX the fields are exactly the same.
953
954The basic format for the following lines is:
955 SFX {flag} {strip} {add} {condition}
956
957{flag} Must be the same as the {flag} used in the first line.
958
959{strip} Characters removed from the basic word. There is no check if
960 the characters are actually there, only the length is used (in
961 bytes). This better match the {condition}, otherwise strange
962 things may happen. If the {strip} length is equal to or
963 longer than the basic word the suffix won't be used.
964 When {strip} is 0 (zero) then nothing is stripped.
965
966{add} Characters added to the basic word, after removing {strip}.
967
968{condition} A simplistic pattern. Only when this matches with a basic
969 word will the suffix be used for that word. This is normally
970 for using one suffix letter with different {add} and {strip}
971 fields for words with different endings.
972 When {condition} is a . (dot) there is no condition.
973 The pattern may contain:
974 - Literal characters.
975 - A set of characters in []. [abc] matches a, b and c.
976 A dash is allowed for a range [a-c], but this is
977 Vim-specific.
978 - A set of characters that starts with a ^, meaning the
979 complement of the specified characters. [^abc] matches any
980 character but a, b and c.
981
982For PFX the fields are the same, but the {strip}, {add} and {condition} apply
983to the start of the word.
984
985Note: Myspell ignores any extra text after the relevant info. Vim requires
986this text to start with a "#" so that mistakes don't go unnoticed. Example:
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000987
988 SFX F 0 in [^i]n # Spion > Spionin ~
989 SFX F 0 nen in # Bauerin > Bauerinnen ~
990
Bram Moolenaar81f1ecb2005-08-25 21:27:31 +0000991Apparently Myspell allows an affix name to appear more than once. Since this
992might also be a mistake, Vim checks for an extra "S". The affix files for
993Myspell that use this feature apparently have this flag. Example:
994
995 SFX a Y 1 S ~
996 SFX a 0 an . ~
997
998 SFX a Y 2 S ~
999 SFX a 0 en . ~
1000 SFX a 0 on . ~
1001
Bram Moolenaar4770d092006-01-12 23:22:24 +00001002
1003AFFIX FLAGS *spell-affix-flags*
1004
1005This is a feature that comes from Hunspell: The affix may specify flags. This
1006works similar to flags specified on a basic word. The flags apply to the
1007basic word plus the affix. Example:
1008
1009 SFX S Y 1 ~
1010 SFX S 0 s . ~
1011
1012 SFX A Y 1 ~
1013 SFX A 0 able/S . ~
1014
1015When the dictionary file contains "drink/AS" then these words are possible:
1016
1017 drink
1018 drinks uses S suffix
1019 drinkable uses A suffix
1020 drinkables uses A suffix and then S suffix
1021
1022Generally the flags of the suffix are added to the flags of the basic word,
1023both are used for the word plus suffix. But the flags of the basic word are
1024only used once for affixes, except that both one prefix and one suffix can be
1025used when both support combining.
1026
1027Specifically, the affix flags can be used for:
1028- Affixes on affixes, as in the example above.
1029- Making the word with the affix rare, by using the |spell-RARE| flag.
1030- Exclude the word with the affix from compounding, by using the
1031 |spell-COMPOUNDFORBIDFLAG| flag.
1032
1033-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1034OLD STUFF
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001035 *spell-affix-rare*
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +00001036An extra item for Vim is the "rare" flag. It must come after the other
1037fields, before a comment. When used then all words that use the affix will be
Bram Moolenaar4770d092006-01-12 23:22:24 +00001038marked as rare words. Examples:
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +00001039
1040 PFX F 0 nene . rare ~
1041 SFX F 0 oin n rare # hardly ever used ~
1042
Bram Moolenaar4770d092006-01-12 23:22:24 +00001043However, if the word also appears as a good word in another way (e.g., in
1044another region) it won't be marked as rare.
Bram Moolenaare13305e2005-06-19 22:54:15 +00001045
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001046 *spell-affix-nocomp*
1047Another extra item for Vim is the "nocomp" flag. It must come after the other
Bram Moolenaar90915b52005-08-21 22:17:52 +00001048fields, before a comment. It can be either before or after "rare". When
1049present then all words that use the affix will not be part of a compound word.
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001050Example:
1051 affix file:
1052 COMPOUNDFLAG c ~
1053 SFX a Y 2 ~
1054 SFX a 0 s . ~
1055 SFX a 0 ize . nocomp ~
1056 dictionary:
1057 word/c ~
1058 util/ac ~
1059
1060This allows for "wordutil" and "wordutils" but not "wordutilize".
Bram Moolenaar4770d092006-01-12 23:22:24 +00001061-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001062
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001063 *spell-PFXPOSTPONE*
Bram Moolenaare13305e2005-06-19 22:54:15 +00001064When an affix file has very many prefixes that apply to many words it's not
1065possible to build the whole word list in memory. This applies to Hebrew (a
1066list with all words is over a Gbyte). In that case applying prefixes must be
1067postponed. This makes spell checking slower. It is indicated by this keyword
1068in the .aff file:
1069
1070 PFXPOSTPONE ~
1071
1072Only prefixes without a chop string can be postponed, prefixes with a chop
Bram Moolenaar78984f52005-08-01 07:19:10 +00001073string will still be included in the word list. An exception if the chop
1074string is one character and equal to the last character of the added string,
1075but in lower case. Thus when the chop string is used to allow the following
1076word to start with an upper case letter.
Bram Moolenaare13305e2005-06-19 22:54:15 +00001077
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001078
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001079WORDS WITH A SLASH *spell-SLASH*
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001080
1081The slash is used in the .dic file to separate the basic word from the affix
Bram Moolenaar33aec762006-01-22 23:30:12 +00001082letters and other flags. Unfortunately, this means you cannot use a slash in
1083a word. Thus "TCP/IP" is not a word but "TCP with the flags "IP". To include
1084a slash in the word put a backslash before it: "TCP\/IP". In the rare case
1085you want to use a backslash inside a word you need to use two backslashes.
1086Any other use of the backslash is reserved for future expansion.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001087
1088
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +00001089KEEP-CASE WORDS *spell-KEEPCASE*
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001090
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +00001091In the affix file a KEEPCASE line can be used to define the affix name used
1092for keep-case words. Example:
Bram Moolenaar45eeb132005-06-06 21:59:07 +00001093
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +00001094 KEEPCASE = ~
Bram Moolenaar45eeb132005-06-06 21:59:07 +00001095
Bram Moolenaar4770d092006-01-12 23:22:24 +00001096This flag is not supported by Myspell. It has the meaning that case matters.
1097This can be used if the word does not have the first letter in upper case at
1098the start of a sentence. Example:
1099
1100 word list matches does not match ~
1101 's morgens/= 's morgens 'S morgens 's Morgens 'S MORGENS
1102 's Morgens 's Morgens 'S MORGENS 'S morgens 's morgens
1103
1104The flag can also be used to avoid that the word matches when it is in all
1105upper-case letters.
Bram Moolenaar45eeb132005-06-06 21:59:07 +00001106
Bram Moolenaare13305e2005-06-19 22:54:15 +00001107
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +00001108RARE WORDS *spell-RARE*
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001109
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +00001110In the affix file a RARE line can be used to define the affix name used for
Bram Moolenaar45eeb132005-06-06 21:59:07 +00001111rare words. Example:
1112
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +00001113 RARE ? ~
Bram Moolenaar45eeb132005-06-06 21:59:07 +00001114
1115Rare words are highlighted differently from bad words. This is to be used for
1116words that are correct for the language, but are hardly ever used and could be
Bram Moolenaar30abd282005-06-22 22:35:10 +00001117a typing mistake anyway. When the same word is found as good it won't be
1118highlighted as rare.
1119
1120
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001121BAD WORDS *spell-BAD*
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001122
Bram Moolenaar30abd282005-06-22 22:35:10 +00001123In the affix file a BAD line can be used to define the affix name used for
1124bad words. Example:
1125
1126 BAD ! ~
1127
1128This can be used to exclude words that would otherwise be good. For example
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +00001129"the the" in the .dic file:
1130
1131 the the/! ~
1132
1133Once a word has been marked as bad it won't be undone by encountering the same
1134word as good.
Bram Moolenaar45eeb132005-06-06 21:59:07 +00001135
Bram Moolenaar4770d092006-01-12 23:22:24 +00001136The flag also applies to the word with affixes, thus this can be used to mark
1137a whole bunch of related words as bad.
1138
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001139 *spell-NEEDAFFIX*
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001140The NEEDAFFIX flag is used to require that a word is used with an affix. The
Bram Moolenaar4770d092006-01-12 23:22:24 +00001141word itself is not a good word (unless there is an empty affix). Example:
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001142
1143 NEEDAFFIX + ~
1144
Bram Moolenaar45eeb132005-06-06 21:59:07 +00001145
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001146COMPOUND WORDS *spell-compound*
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001147
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001148A compound word is a longer word made by concatenating words that appear in
1149the .dic file. To specify which words may be concatenated a character is
1150used. This character is put in the list of affixes after the word. We will
1151call this character a flag here. Obviously these flags must be different from
1152any affix IDs used.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001153
1154 *spell-COMPOUNDFLAG*
Bram Moolenaar4770d092006-01-12 23:22:24 +00001155The Myspell compatible method uses one flag, specified with COMPOUNDFLAG. All
1156words with this flag combine in any order. This means there is no control
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001157over which word comes first. Example:
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001158 COMPOUNDFLAG c ~
1159
1160 *spell-COMPOUNDFLAGS*
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001161A more advanced method to specify how compound words can be formed uses
1162multiple items with multiple flags. This is not compatible with Myspell 3.0.
1163Let's start with an example:
1164 COMPOUNDFLAGS c+ ~
1165 COMPOUNDFLAGS se ~
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001166
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001167The first line defines that words with the "c" flag can be concatenated in any
1168order. The second line defines compound words that are made of one word with
1169the "s" flag and one word with the "e" flag. With this dictionary:
1170 bork/c ~
1171 onion/s ~
1172 soup/e ~
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001173
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001174You can make these words:
1175 bork
1176 borkbork
1177 borkborkbork
1178 (etc.)
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001179 onion
1180 soup
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001181 onionsoup
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001182
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001183The COMPOUNDFLAGS item may appear multiple times. The argument is made out of
1184one or more groups, where each group can be:
1185 one flag e.g., c
1186 alternate flags inside [] e.g., [abc]
1187Optionally this may be followed by:
1188 * the group appears zero or more times, e.g., sm*e
1189 + the group appears one or more times, e.g., c+
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001190
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001191This is similar to the regexp pattern syntax (but not the same!). A few
1192examples with the sequence of word flags they require:
1193 COMPOUNDFLAGS x+ x xx xxx etc.
1194 COMPOUNDFLAGS yz yz
1195 COMPOUNDFLAGS x+z xz xxz xxxz etc.
1196 COMPOUNDFLAGS yx+ yx yxx yxxx etc.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001197
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001198 COMPOUNDFLAGS [abc]z az bz cz
1199 COMPOUNDFLAGS [abc]+z az aaz abaz bz baz bcbz cz caz cbaz etc.
1200 COMPOUNDFLAGS a[xyz]+ ax axx axyz ay ayx ayzz az azy azxy etc.
1201 COMPOUNDFLAGS sm*e se sme smme smmme etc.
1202 COMPOUNDFLAGS s[xyz]*e se sxe sxye sxyxe sye syze sze szye szyxe etc.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001203
Bram Moolenaara6c840d2005-08-22 22:59:46 +00001204A specific example: Allow a compound to be made of two words and a dash:
1205 In the .aff file:
1206 COMPOUNDFLAGS sde ~
1207 NEEDAFFIX x ~
1208 COMPOUNDMAX 3 ~
1209 COMPOUNDMIN 1 ~
1210 In the .dic file:
1211 start/s ~
1212 end/e ~
1213 -/xd ~
1214
1215This allows for the word "start-end", but not "startend".
1216
Bram Moolenaar4770d092006-01-12 23:22:24 +00001217 *spell-NEEDCOMPOUND*
1218The NEEDCOMPOUND flag is used to require that a word is used as part of a
1219compound word. The word itself is not a good word. Example:
1220
1221 NEEDCOMPOUND & ~
1222
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001223 *spell-COMPOUNDMIN*
Bram Moolenaarac6e65f2005-08-29 22:25:38 +00001224The minimal character length of a word used for compounding is specified with
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001225COMPOUNDMIN. Example:
1226 COMPOUNDMIN 5 ~
1227
Bram Moolenaarac6e65f2005-08-29 22:25:38 +00001228When omitted there is no minimal length. Obviously you could just leave out
1229the compound flag from short words instead, this feature is present for
1230compatibility with Myspell.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001231
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001232 *spell-COMPOUNDMAX*
1233The maximum number of words that can be concatenated into a compound word is
1234specified with COMPOUNDMAX. Example:
1235 COMPOUNDMAX 3 ~
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001236
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001237When omitted there is no maximum. It applies to all compound words.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001238
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001239To set a limit for words with specific flags make sure the items in
1240COMPOUNDFLAGS where they appear don't allow too many words.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001241
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001242 *spell-COMPOUNDSYLMAX*
1243The maximum number of syllables that a compound word may contain is specified
1244with COMPOUNDSYLMAX. Example:
1245 COMPOUNDSYLMAX 6 ~
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001246
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001247This has no effect if there is no SYLLABLE item. Without COMPOUNDSYLMAX there
1248is no limit on the number of syllables.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001249
Bram Moolenaara6c840d2005-08-22 22:59:46 +00001250If both COMPOUNDMAX and COMPOUNDSYLMAX are defined, a compound word is
1251accepted if it fits one of the criteria, thus is either made from up to
1252COMPOUNDMAX words or contains up to COMPOUNDSYLMAX syllables.
1253
Bram Moolenaar4770d092006-01-12 23:22:24 +00001254 *spell-COMPOUNDFORBIDFLAG*
1255The COMPOUNDFORBIDFLAG specifies a flag that can be used on an affix. It
1256means that the word plus affix cannot be used in a compound word.
1257NOT IMPLEMENTED YET.
1258
1259 *spell-COMPOUNDPERMITFLAG*
1260The COMPOUNDPERMITFLAG specifies a flag that can be used on an affix. It
1261means that the word plus affix can also be used in a compound word in a way
1262where the affix ends up halfway the word.
1263NOT IMPLEMENTED YET.
1264
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001265 *spell-SYLLABLE*
1266The SYLLABLE item defines characters or character sequences that are used to
1267count the number of syllables in a word. Example:
1268 SYLLABLE aáeéiíoóöõuúüûy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui ~
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001269
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001270Before the first slash is the set of characters that are counted for one
1271syllable, also when repeated and mixed, until the next character that is not
1272in this set. After the slash come sequences of characters that are counted
1273for one syllable. These are preferred over using characters from the set.
1274With the example "ideeen" has three syllables, counted by "i", "ee" and "e".
1275
1276Only case-folded letters need to be included.
1277
1278Above another way to restrict compounding was mentioned above: adding "nocomp"
1279after an affix causes all words that are made with that affix not be be used
1280for compounding. |spell-affix-nocomp|
1281
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001282
1283UNLIMITED COMPOUNDING *spell-NOBREAK*
1284
1285For some languages, such as Thai, there is no space in between words. This
1286looks like all words are compounded. To specify this use the NOBREAK item in
1287the affix file, without arguments:
1288 NOBREAK ~
1289
1290Vim will try to figure out where one word ends and a next starts. When there
1291are spelling mistakes this may not be quite right.
1292
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001293
Bram Moolenaar4770d092006-01-12 23:22:24 +00001294 *spell-COMMON*
1295Common words can be specified with the COMMON item. This will give better
1296suggestions when editing a short file. Example:
1297
1298 COMMON the of to and a in is it you that he was for on are ~
1299
1300The words must be separated by white space, up to 25 per line.
1301When multiple regions are specified in a ":mkspell" command the common words
1302for all regions are combined and used for all regions.
1303
1304 *spell-NOSPLITSUGS*
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00001305This item indicates that splitting a word to make suggestions is not a good
1306idea. Split-word suggestions will appear only when there are few similar
1307words.
Bram Moolenaar4770d092006-01-12 23:22:24 +00001308
1309 NOSPLITSUGS ~
1310
1311 *spell-NOSUGGEST*
1312The flag specified with NOSUGGEST can be used for words that will not be
1313suggested. Can be used for obscene words.
1314
1315 NOSUGGEST % ~
1316
Bram Moolenaar4770d092006-01-12 23:22:24 +00001317
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001318REPLACEMENTS *spell-REP*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001319
1320In the affix file REP items can be used to define common mistakes. This is
1321used to make spelling suggestions. The items define the "from" text and the
1322"to" replacement. Example:
1323
1324 REP 4 ~
1325 REP f ph ~
1326 REP ph f ~
1327 REP k ch ~
1328 REP ch k ~
1329
Bram Moolenaar6e7c7f32005-08-24 22:16:11 +00001330The first line specifies the number of REP lines following. Vim ignores the
Bram Moolenaar4770d092006-01-12 23:22:24 +00001331number, but it must be there (for compatibility with Myspell).
Bram Moolenaar6e7c7f32005-08-24 22:16:11 +00001332
Bram Moolenaard042c562005-06-30 22:04:15 +00001333Don't include simple one-character replacements or swaps. Vim will try these
1334anyway. You can include whole words if you want to, but you might want to use
1335the "file:" item in 'spellsuggest' instead.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001336
Bram Moolenaar1e015462005-09-25 22:16:38 +00001337You can include a space by using an underscore:
1338
1339 REP the_the the ~
1340
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001341
Bram Moolenaara40ceaf2006-01-13 22:35:40 +00001342SIMILAR CHARACTERS *spell-MAP* *E783*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001343
Bram Moolenaard042c562005-06-30 22:04:15 +00001344In the affix file MAP items can be used to define letters that are very much
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001345alike. This is mostly used for a letter with different accents. This is used
1346to prefer suggestions with these letters substituted. Example:
1347
1348 MAP 2 ~
1349 MAP eéëêè ~
1350 MAP uüùúû ~
1351
Bram Moolenaar6e7c7f32005-08-24 22:16:11 +00001352The first line specifies the number of MAP lines following. Vim ignores the
1353number, but the line must be there.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001354
Bram Moolenaard042c562005-06-30 22:04:15 +00001355Each letter must appear in only one of the MAP items. It's a bit more
1356efficient if the first letter is ASCII or at least one without accents.
Bram Moolenaare7566042005-06-17 22:00:15 +00001357
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001358
Bram Moolenaar4770d092006-01-12 23:22:24 +00001359.SUG FILE *spell-NOSUGFILE*
1360
1361When soundfolding is specified in the affix file then ":mkspell" will normally
Bram Moolenaard12f5c12006-01-25 22:10:52 +00001362produce a .sug file next to the .spl file. This file is used to find
1363suggestions by their sound-a-like form quickly. At the cost of a lot of
1364memory (the amount depends on the number of words, |:mkspell| will display an
1365estimate when it's done).
Bram Moolenaar4770d092006-01-12 23:22:24 +00001366
1367To avoid producing a .sug file use this item in the affix file:
1368
1369 NOSUGFILE ~
1370
Bram Moolenaard12f5c12006-01-25 22:10:52 +00001371Users can simply omit the .sug file if they don't want to use it.
1372
Bram Moolenaar4770d092006-01-12 23:22:24 +00001373
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001374SOUND-A-LIKE *spell-SAL*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001375
1376In the affix file SAL items can be used to define the sounds-a-like mechanism
1377to be used. The main items define the "from" text and the "to" replacement.
Bram Moolenaard042c562005-06-30 22:04:15 +00001378Simplistic example:
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001379
1380 SAL CIA X ~
1381 SAL CH X ~
1382 SAL C K ~
1383 SAL K K ~
1384
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +00001385There are a few rules and this can become quite complicated. An explanation
Bram Moolenaard042c562005-06-30 22:04:15 +00001386how it works can be found in the Aspell manual:
Bram Moolenaar42eeac32005-06-29 22:40:58 +00001387http://aspell.net/man-html/Phonetic-Code.html.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001388
1389There are a few special items:
1390
1391 SAL followup true ~
1392 SAL collapse_result true ~
1393 SAL remove_accents true ~
1394
1395"1" has the same meaning as "true". Any other value means "false".
1396
Bram Moolenaar42eeac32005-06-29 22:40:58 +00001397
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001398SIMPLE SOUNDFOLDING *spell-SOFOFROM* *spell-SOFOTO*
Bram Moolenaar42eeac32005-06-29 22:40:58 +00001399
1400The SAL mechanism is complex and slow. A simpler mechanism is mapping all
1401characters to another character, mapping similar sounding characters to the
1402same character. At the same time this does case folding. You can not have
Bram Moolenaard042c562005-06-30 22:04:15 +00001403both SAL items and simple soundfolding.
Bram Moolenaar42eeac32005-06-29 22:40:58 +00001404
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +00001405There are two items required: one to specify the characters that are mapped
Bram Moolenaar42eeac32005-06-29 22:40:58 +00001406and one that specifies the characters they are mapped to. They must have
1407exactly the same number of characters. Example:
1408
1409 SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~
1410 SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkes ~
1411
1412In the example all vowels are mapped to the same character 'e'. Another
Bram Moolenaard042c562005-06-30 22:04:15 +00001413method would be to leave out all vowels. Some characters that sound nearly
1414the same and are often mixed up, such as 'm' and 'n', are mapped to the same
1415character. Don't do this too much, all words will start looking alike.
Bram Moolenaar42eeac32005-06-29 22:40:58 +00001416
1417Characters that do not appear in SOFOFROM will be left out, except that all
1418white space is replaced by one space. Sequences of the same character in
1419SOFOFROM are replaced by one.
1420
1421You can use the |soundfold()| function to try out the results. Or set the
Bram Moolenaarcc016f52005-12-10 20:23:46 +00001422'verbose' option to see the score in the output of the |z=| command.
Bram Moolenaar42eeac32005-06-29 22:40:58 +00001423
1424
Bram Moolenaar4770d092006-01-12 23:22:24 +00001425UNSUPPORTED ITEMS *spell-affix-not-supported*
1426
1427These items appear in the affix file of other spell checkers. In Vim they are
1428ignored, not supported or defined in another way.
1429
1430ACCENT (Hunspell) *spell-ACCENT*
1431 Use MAP instead. |spell-MAP|
1432
1433CHECKCOMPOUNDCASE (Hunspell) *spell-CHECKCOMPOUNDCASE*
1434 Disallow uppercase letters at compound word boundaries.
1435 Not supported.
1436
1437CHECKCOMPOUNDDUP (Hunspell) *spell-CHECKCOMPOUNDDUP*
1438 Disallow using the same word twice in a compound. Not
1439 supported.
1440
1441CHECKCOMPOUNDREP (Hunspell) *spell-CHECKCOMPOUNDREP*
1442 Something about using REP items and compound words. Not
1443 supported.
1444
1445CHECKCOMPOUNDTRIPLE (Hunspell) *spell-CHECKCOMPOUNDTRIPLE*
1446 Forbid three identical characters when compounding. Not
1447 supported.
1448
1449CHECKCOMPOUNDPATTERN (Hunspell) *spell-CHECKCOMPOUNDPATTERN*
1450 Forbid compounding when patterns match. Not supported.
1451
1452CIRCUMFIX (Hunspell) *spell-CIRCUMFIX*
1453 This means a prefix and suffix must be added at the same time.
1454 Instead only specify the suffix, and give the that suffix two
1455 flags: The required prefix and the NEEDAFFIX flag.
1456 |spell-NEEDAFFIX|
1457
1458COMPLEXPREFIXES (Hunspell) *spell-COMPLEXPREFIXES*
1459 Enables using two prefixes. Not supported.
1460
1461COMPOUNDBEGIN (Hunspell) *spell-COMPOUNDBEGIN*
1462 Use COMPOUNDFLAGS instead. |spell-COMPOUNDFLAGS|
1463
1464COMPOUNDEND (Hunspell) *spell-COMPOUNDEND*
1465 Use COMPOUNDFLAGS instead. |spell-COMPOUNDFLAGS|
1466
1467COMPOUNDMIDDLE (Hunspell) *spell-COMPOUNDMIDDLE*
1468 Use COMPOUNDFLAGS instead. |spell-COMPOUNDFLAGS|
1469
1470COMPOUNDROOT (Hunspell) *spell-COMPOUNDROOT*
1471 Flag for words in the dictionary that are already a compound.
1472 Vim doesn't use it.
1473
1474COMPOUNDSYLLABLE (Hunspell) *spell-COMPOUNDSYLLABLE*
1475 Use SYLLABLE and COMPOUNDSYLMAX instead. |spell-SYLLABLE|
1476 |spell-COMPOUNDSYLMAX|
1477
1478COMPOUNDWORDMAX (Hunspell) *spell-COMPOUNDWORDMAX*
1479 Use COMPOUNDMAX instead. |spell-COMPOUNDMAX|
1480
1481FORBIDDENWORD (Hunspell) *spell-FORBIDDENWORD*
1482 Use BAD instead. |spell-BAD|
1483
1484HOME (Hunspell) *spell-HOME*
1485 Specifies the website for the language. Not supported.
1486
1487LANG (Hunspell) *spell-LANG*
1488 This specifies language-specific behavior. This actually
1489 moves part of the language knowledge into the program,
1490 therefore Vim does not support it. Each language property
1491 must be specified separately.
1492
1493LEMMA_PRESENT (Hunspell) *spell-LEMMA_PRESENT*
1494 Only needed for mprphological analysis.
1495
1496MAXNGRAMSUGS (Hunspell) *spell-MAXNGRAMSUGS*
1497 Not supported.
1498
1499NAME (Hunspell) *spell-NAME*
1500 Specifies the name of the language. Not supported.
1501
1502ONLYINCOMPOUND (Hunspell) *spell-ONLYINCOMPOUND*
1503 Use NEEDCOMPOUND instead. |spell-NEEDCOMPOUND|
1504
1505PSEUDOROOT (Hunspell) *spell-PSEUDOROOT*
1506 Use NEEDAFFIX instead. |spell-NEEDAFFIX|
1507
1508SUGSWITHDOTS (Hunspell) *spell-SUGSWITHDOTS*
1509 Adds dots to suggestions. Vim doesn't need this.
1510
1511SYLLABLENUM (Hunspell) *spell-SYLLABLENUM*
1512 Not supported.
1513
1514TRY (Myspell, Hunspell, others) *spell-TRY*
1515 Vim does not use the TRY item, it is ignored. For making
1516 suggestions the actual characters in the words are used.
1517
1518VERSION (Hunspell) *spell-VERSION*
1519 Specifies the version for the language. Not supported.
1520
1521WORDCHARS (Hunspell) *spell-WORDCHARS*
1522 Used to recognize words. Vim doesn't need it, because there
1523 is no need to separate words before checking them (using a
1524 trie instead of a hashtable).
1525
Bram Moolenaar217ad922005-03-20 22:37:15 +00001526 vim:tw=78:sw=4:ts=8:ft=help:norl: