blob: f9559c825f47d4de086f191f337ec3e58192fbb2 [file] [log] [blame]
Bram Moolenaard12f5c12006-01-25 22:10:52 +00001*spell.txt* For Vim version 7.0aa. Last change: 2006 Jan 25
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 Moolenaar82cf9b62005-06-07 21:09:25 +000087
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000088 *zW*
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000089zW Like "zw" but add the word to the internal word list
90 |internal-wordlist|.
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000091
Bram Moolenaar520470a2005-06-16 21:59:56 +000092 *:spe* *:spellgood*
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000093:[count]spe[llgood] {word}
Bram Moolenaar53180ce2005-07-05 21:48:14 +000094 Add {word} as a good word to 'spellfile', like with
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000095 "zg". Without count the first name is used, with a
96 count of two the second entry, etc.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000097
Bram Moolenaar53180ce2005-07-05 21:48:14 +000098:spe[llgood]! {word} Add {word} as a good word to the internal word list,
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000099 like with "zG".
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000100
Bram Moolenaar520470a2005-06-16 21:59:56 +0000101 *:spellw* *:spellwrong*
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000102:[count]spellw[rong] {word}
Bram Moolenaar53180ce2005-07-05 21:48:14 +0000103 Add {word} as a wrong (bad) word to 'spellfile', as
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000104 with "zw". Without count the first name is used, with
105 a count of two the second entry, etc.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000106
Bram Moolenaar53180ce2005-07-05 21:48:14 +0000107:spellw[rong]! {word} Add {word} as a wrong (bad) word to the internal word
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000108 list.
109
Bram Moolenaarf461c8e2005-06-25 23:04:51 +0000110After adding a word to 'spellfile' with the above commands its associated
Bram Moolenaard042c562005-06-30 22:04:15 +0000111".spl" file will automatically be updated and reloaded. If you change
112'spellfile' manually you need to use the |:mkspell| command. This sequence of
113commands mostly works well: >
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000114 :edit <file in 'spellfile'>
Bram Moolenaarf461c8e2005-06-25 23:04:51 +0000115< (make changes to the spell file) >
116 :mkspell! %
117
118More details about the 'spellfile' format below |spell-wordlist-format|.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000119
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000120 *internal-wordlist*
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000121The internal word list is used for all buffers where 'spell' is set. It is
122not stored, it is lost when you exit Vim. It is also cleared when 'encoding'
123is set.
124
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000125
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000126Finding suggestions for bad words:
Bram Moolenaarcc016f52005-12-10 20:23:46 +0000127 *z=*
128z= For the word under/after the cursor suggest correctly
Bram Moolenaard042c562005-06-30 22:04:15 +0000129 spelled words. This also works to find alternatives
130 for a word that is not highlighted as a bad word,
131 e.g., when the word after it is bad.
Bram Moolenaar7df351e2006-01-23 22:30:28 +0000132 In Visual mode the highlighted text is taken as the
133 word to be replaced.
134 The results are sorted on similarity to the word being
135 replaced.
Bram Moolenaar90915b52005-08-21 22:17:52 +0000136 This may take a long time. Hit CTRL-C when you get
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000137 bored.
Bram Moolenaar90915b52005-08-21 22:17:52 +0000138
139 If the command is used without a count the
140 alternatives are listed and you can enter the number
141 of your choice or press <Enter> if you don't want to
142 replace. You can also use the mouse to click on your
143 choice (only works if the mouse can be used in Normal
144 mode and when there are no line wraps). Click on the
145 first line (the header) to cancel.
146
147 If a count is used that suggestion is used, without
Bram Moolenaarcc016f52005-12-10 20:23:46 +0000148 prompting. For example, "1z=" always takes the first
Bram Moolenaar90915b52005-08-21 22:17:52 +0000149 suggestion.
150
151 If 'verbose' is non-zero a score will be displayed
152 with the suggestions to indicate the likeliness to the
153 badly spelled word (the higher the score the more
154 different).
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000155 When a word was replaced the redo command "." will
156 repeat the word replacement. This works like "ciw",
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000157 the good word and <Esc>. This does NOT work for Thai
158 and other languages without spaces between words.
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000159
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +0000160 *:spellr* *:spellrepall* *E752* *E753*
Bram Moolenaarcc016f52005-12-10 20:23:46 +0000161:spellr[epall] Repeat the replacement done by |z=| for all matches
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +0000162 with the replaced word in the current window.
163
Bram Moolenaar488c6512005-08-11 20:09:58 +0000164In Insert mode, when the cursor is after a badly spelled word, you can use
165CTRL-X s to find suggestions. This works like Insert mode completion. Use
166CTRL-N to use the next suggestion, CTRL-P to go back. |i_CTRL-X_s|
167
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000168The 'spellsuggest' option influences how the list of suggestions is generated
169and sorted. See |'spellsuggest'|.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000170
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000171The 'spellcapcheck' option is used to check the first word of a sentence
172starts with a capital. This doesn't work for the first word in the file.
173When there is a line break right after a sentence the highlighting of the next
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +0000174line may be postponed. Use |CTRL-L| when needed. Also see |set-spc-auto| for
175how it can be set automatically when 'spelllang' is set.
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000176
Bram Moolenaar4770d092006-01-12 23:22:24 +0000177Vim counts the number of times a good word is encountered. This is used to
178sort the suggestions: words that have been seen before get a small bonus,
179words that have been seen often get a bigger bonus. The COMMON item in the
180affix file can be used to define common words, so that this mechanism also
181works in a new or short file |spell-COMMON|.
182
Bram Moolenaard042c562005-06-30 22:04:15 +0000183==============================================================================
1842. Remarks on spell checking *spell-remarks*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000185
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000186PERFORMANCE
187
Bram Moolenaard042c562005-06-30 22:04:15 +0000188Vim does on-the-fly spell checking. To make this work fast the word list is
189loaded in memory. Thus this uses a lot of memory (1 Mbyte or more). There
190might also be a noticeable delay when the word list is loaded, which happens
191when 'spell' is set and when 'spelllang' is set while 'spell' was already set.
192To minimize the delay each word list is only loaded once, it is not deleted
193when 'spelllang' is made empty or 'spell' is reset. When 'encoding' is set
194all the word lists are reloaded, thus you may notice a delay then too.
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000195
196
Bram Moolenaar217ad922005-03-20 22:37:15 +0000197REGIONS
198
199A word may be spelled differently in various regions. For example, English
200comes in (at least) these variants:
201
202 en all regions
Bram Moolenaar5c5474b2005-04-19 21:40:26 +0000203 en_au Australia
Bram Moolenaar217ad922005-03-20 22:37:15 +0000204 en_ca Canada
Bram Moolenaar5c5474b2005-04-19 21:40:26 +0000205 en_gb Great Britain
206 en_nz New Zealand
207 en_us USA
Bram Moolenaar217ad922005-03-20 22:37:15 +0000208
209Words that are not used in one region but are used in another region are
Bram Moolenaar520470a2005-06-16 21:59:56 +0000210highlighted with SpellLocal |hl-SpellLocal|.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000211
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000212Always use lowercase letters for the language and region names.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000213
Bram Moolenaar3638c682005-06-08 22:05:14 +0000214When adding a word with |zg| or another command it's always added for all
215regions. You can change that by manually editing the 'spellfile'. See
Bram Moolenaar0dc065e2005-07-04 22:49:24 +0000216|spell-wordlist-format|. Note that the regions as specified in the files in
Bram Moolenaar16d8f872005-11-26 23:46:11 +0000217'spellfile' are only used when all entries in 'spelllang' specify the same
Bram Moolenaar0dc065e2005-07-04 22:49:24 +0000218region (not counting files specified by their .spl name).
Bram Moolenaar3638c682005-06-08 22:05:14 +0000219
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000220 *spell-german*
Bram Moolenaarae5bce12005-08-15 21:41:48 +0000221Specific exception: For German these special regions are used:
222 de all German words accepted
223 de_de old and new spelling
224 de_19 old spelling
225 de_20 new spelling
226 de_at Austria
227 de_ch Switzerland
228
Bram Moolenaar92d640f2005-09-05 22:11:52 +0000229 *spell-russian*
230Specific exception: For Russian these special regions are used:
231 ru all Russian words accepted
232 ru_ru "IE" letter spelling
233 ru_yo "YO" letter spelling
234
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000235 *spell-yiddish*
236Yiddish requires using "utf-8" encoding, because of the special characters
237used. If you are using latin1 Vim will use transliterated (romanized) Yiddish
238instead. If you want to use transliterated Yiddish with utf-8 use "yi-tr".
239In a table:
240 'encoding' 'spelllang'
241 utf-8 yi Yiddish
242 latin1 yi transliterated Yiddish
243 utf-8 yi-tr transliterated Yiddish
244
Bram Moolenaar217ad922005-03-20 22:37:15 +0000245
Bram Moolenaar3b506942005-06-23 22:36:45 +0000246SPELL FILES *spell-load*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000247
248Vim searches for spell files in the "spell" subdirectory of the directories in
Bram Moolenaar3638c682005-06-08 22:05:14 +0000249'runtimepath'. The name is: LL.EEE.spl, where:
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000250 LL the language name
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000251 EEE the value of 'encoding'
Bram Moolenaar217ad922005-03-20 22:37:15 +0000252
Bram Moolenaar3b506942005-06-23 22:36:45 +0000253The value for "LL" comes from 'spelllang', but excludes the region name.
254Examples:
255 'spelllang' LL ~
256 en_us en
257 en-rare en-rare
258 medical_ca medical
259
Bram Moolenaar3638c682005-06-08 22:05:14 +0000260Only the first file is loaded, the one that is first in 'runtimepath'. If
261this succeeds then additionally files with the name LL.EEE.add.spl are loaded.
262All the ones that are found are used.
263
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000264Additionally, the files related to the names in 'spellfile' are loaded. These
265are the files that |zg| and |zw| add good and wrong words to.
Bram Moolenaar3b506942005-06-23 22:36:45 +0000266
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000267Exceptions:
268- Vim uses "latin1" when 'encoding' is "iso-8859-15". The euro sign doesn't
269 matter for spelling.
270- When no spell file for 'encoding' is found "ascii" is tried. This only
271 works for languages where nearly all words are ASCII, such as English. It
272 helps when 'encoding' is not "latin1", such as iso-8859-2, and English text
Bram Moolenaar3638c682005-06-08 22:05:14 +0000273 is being edited. For the ".add" files the same name as the found main
274 spell file is used.
275
276For example, with these values:
277 'runtimepath' is "~/.vim,/usr/share/vim70,~/.vim/after"
278 'encoding' is "iso-8859-2"
279 'spelllang' is "pl"
280
281Vim will look for:
2821. ~/.vim/spell/pl.iso-8859-2.spl
2832. /usr/share/vim70/spell/pl.iso-8859-2.spl
2843. ~/.vim/spell/pl.iso-8859-2.add.spl
2854. /usr/share/vim70/spell/pl.iso-8859-2.add.spl
2865. ~/.vim/after/spell/pl.iso-8859-2.add.spl
287
288This assumes 1. is not found and 2. is found.
289
290If 'encoding' is "latin1" Vim will look for:
2911. ~/.vim/spell/pl.latin1.spl
2922. /usr/share/vim70/spell/pl.latin1.spl
2933. ~/.vim/after/spell/pl.latin1.spl
2944. ~/.vim/spell/pl.ascii.spl
2955. /usr/share/vim70/spell/pl.ascii.spl
2966. ~/.vim/after/spell/pl.ascii.spl
297
298This assumes none of them are found (Polish doesn't make sense when leaving
299out the non-ASCII characters).
Bram Moolenaar217ad922005-03-20 22:37:15 +0000300
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000301Spelling for EBCDIC is currently not supported.
302
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000303A spell file might not be available in the current 'encoding'. See
304|spell-mkspell| about how to create a spell file. Converting a spell file
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000305with "iconv" will NOT work!
Bram Moolenaar217ad922005-03-20 22:37:15 +0000306
Bram Moolenaara40ceaf2006-01-13 22:35:40 +0000307 *spell-sug-file* *E781*
Bram Moolenaar4770d092006-01-12 23:22:24 +0000308If there is a file with exactly the same name as the ".spl" file but ending in
309".sug", that file will be used for giving better suggestions. It isn't loaded
310before suggestions are made to reduce memory use.
311
Bram Moolenaara40ceaf2006-01-13 22:35:40 +0000312 *E758* *E759* *E778* *E779* *E780* *E782*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000313When loading a spell file Vim checks that it is properly formatted. If you
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000314get an error the file may be truncated, modified or intended for another Vim
315version.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000316
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000317
318WORDS
319
320Vim uses a fixed method to recognize a word. This is independent of
321'iskeyword', so that it also works in help files and for languages that
322include characters like '-' in 'iskeyword'. The word characters do depend on
323'encoding'.
324
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000325The table with word characters is stored in the main .spl file. Therefore it
326matters what the current locale is when generating it! A .add.spl file does
Bram Moolenaarf461c8e2005-06-25 23:04:51 +0000327not contain a word table though.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000328
Bram Moolenaar3638c682005-06-08 22:05:14 +0000329A word that starts with a digit is always ignored. That includes hex numbers
330in the form 0xff and 0XFF.
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000331
332
Bram Moolenaar30abd282005-06-22 22:35:10 +0000333WORD COMBINATIONS
334
335It is possible to spell-check words that include a space. This is used to
336recognize words that are invalid when used by themselves, e.g. for "et al.".
337It can also be used to recognize "the the" and highlight it.
338
339The number of spaces is irrelevant. In most cases a line break may also
340appear. However, this makes it difficult to find out where to start checking
341for spelling mistakes. When you make a change to one line and only that line
342is redrawn Vim won't look in the previous line, thus when "et" is at the end
343of the previous line "al." will be flagged as an error. And when you type
344"the<CR>the" the highlighting doesn't appear until the first line is redrawn.
345Use |CTRL-L| to redraw right away. "[s" will also stop at a word combination
346with a line break.
347
348When encountering a line break Vim skips characters such as '*', '>' and '"',
349so that comments in C, shell and Vim code can be spell checked.
350
351
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +0000352SYNTAX HIGHLIGHTING *spell-syntax*
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000353
354Files that use syntax highlighting can specify where spell checking should be
355done:
356
Bram Moolenaar3638c682005-06-08 22:05:14 +00003571. everywhere default
3582. in specific items use "contains=@Spell"
3593. everywhere but specific items use "contains=@NoSpell"
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000360
Bram Moolenaar3638c682005-06-08 22:05:14 +0000361For the second method adding the @NoSpell cluster will disable spell checking
362again. This can be used, for example, to add @Spell to the comments of a
363program, and add @NoSpell for items that shouldn't be checked.
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000364
Bram Moolenaar30abd282005-06-22 22:35:10 +0000365
366VIM SCRIPTS
367
368If you want to write a Vim script that does something with spelling, you may
369find these functions useful:
370
371 spellbadword() find badly spelled word at the cursor
372 spellsuggest() get list of spelling suggestions
Bram Moolenaard042c562005-06-30 22:04:15 +0000373 soundfold() get the sound-a-like version of a word
Bram Moolenaar30abd282005-06-22 22:35:10 +0000374
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +0000375
376SETTING 'spellcapcheck' AUTOMATICALLY *set-spc-auto*
377
378After the 'spelllang' option has been set successfully, Vim will source the
379files "spell/LANG.vim" in 'runtimepath'. "LANG" is the value of 'spelllang'
380up to the first comma, dot or underscore. This can be used to set options
381specifically for the language, especially 'spellcapcheck'.
382
383The distribution includes a few of these files. Use this command to see what
384they do: >
385 :next $VIMRUNTIME/spell/*.vim
386
387Note that the default scripts don't set 'spellcapcheck' if it was changed from
388the default value. This assumes the user prefers another value then.
389
Bram Moolenaarae5bce12005-08-15 21:41:48 +0000390
391DOUBLE SCORING *spell-double-scoring*
392
393The 'spellsuggest' option can be used to select "double" scoring. This
394mechanism is based on the principle that there are two kinds of spelling
395mistakes:
396
3971. You know how to spell the word, but mistype something. This results in a
398 small editing distance (character swapped/omitted/inserted) and possibly a
399 word that sounds completely different.
400
4012. You don't know how to spell the word and type something that sounds right.
402 The edit distance can be big but the word is similar after sound-folding.
403
404Since scores for these two mistakes will be very different we use a list
405for each and mix them.
406
407The sound-folding is slow and people that know the language won't make the
408second kind of mistakes. Therefore 'spellsuggest' can be set to select the
409preferred method for scoring the suggestions.
410
Bram Moolenaar217ad922005-03-20 22:37:15 +0000411==============================================================================
Bram Moolenaard042c562005-06-30 22:04:15 +00004123. Generating a spell file *spell-mkspell*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000413
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000414Vim uses a binary file format for spelling. This greatly speeds up loading
415the word list and keeps it small.
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000416 *.aff* *.dic* *Myspell*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000417You can create a Vim spell file from the .aff and .dic files that Myspell
418uses. Myspell is used by OpenOffice.org and Mozilla. You should be able to
419find them here:
420 http://lingucomponent.openoffice.org/spell_dic.html
Bram Moolenaar30abd282005-06-22 22:35:10 +0000421You can also use a plain word list. The results are the same, the choice
Bram Moolenaard042c562005-06-30 22:04:15 +0000422depends on what word lists you can find.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000423
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +0000424If you install Aap (from www.a-a-p.org) you can use the recipes in the
425runtime/spell/??/ directories. Aap will take care of downloading the files,
426apply patches needed for Vim and build the .spl file.
427
Bram Moolenaare13305e2005-06-19 22:54:15 +0000428Make sure your current locale is set properly, otherwise Vim doesn't know what
429characters are upper/lower case letters. If the locale isn't available (e.g.,
430when using an MS-Windows codepage on Unix) add tables to the .aff file
Bram Moolenaar3b506942005-06-23 22:36:45 +0000431|spell-affix-chars|. If the .aff file doesn't define a table then the word
432table of the currently active spelling is used. If spelling is not active
433then Vim will try to guess.
Bram Moolenaare13305e2005-06-19 22:54:15 +0000434
Bram Moolenaar3b506942005-06-23 22:36:45 +0000435 *:mksp* *:mkspell*
436:mksp[ell][!] [-ascii] {outname} {inname} ...
Bram Moolenaar16d8f872005-11-26 23:46:11 +0000437 Generate a Vim spell file from word lists. Example: >
Bram Moolenaard042c562005-06-30 22:04:15 +0000438 :mkspell /tmp/nl nl_NL.words
Bram Moolenaar3b506942005-06-23 22:36:45 +0000439< *E751*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000440 When {outname} ends in ".spl" it is used as the output
441 file name. Otherwise it should be a language name,
Bram Moolenaar3b506942005-06-23 22:36:45 +0000442 such as "en", without the region name. The file
443 written will be "{outname}.{encoding}.spl", where
444 {encoding} is the value of the 'encoding' option.
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000445
Bram Moolenaard042c562005-06-30 22:04:15 +0000446 When the output file already exists [!] must be used
Bram Moolenaar520470a2005-06-16 21:59:56 +0000447 to overwrite it.
448
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000449 When the [-ascii] argument is present, words with
450 non-ascii characters are skipped. The resulting file
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000451 ends in "ascii.spl".
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000452
453 The input can be the Myspell format files {inname}.aff
454 and {inname}.dic. If {inname}.aff does not exist then
455 {inname} is used as the file name of a plain word
456 list.
457
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000458 Multiple {inname} arguments can be given to combine
459 regions into one Vim spell file. Example: >
460 :mkspell ~/.vim/spell/en /tmp/en_US /tmp/en_CA /tmp/en_AU
461< This combines the English word lists for US, CA and AU
462 into one en.spl file.
463 Up to eight regions can be combined. *E754* *755*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000464 The REP and SAL items of the first .aff file where
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000465 they appear are used. |spell-REP| |spell-SAL|
Bram Moolenaar217ad922005-03-20 22:37:15 +0000466
Bram Moolenaar30abd282005-06-22 22:35:10 +0000467 This command uses a lot of memory, required to find
Bram Moolenaar8aff23a2005-08-19 20:40:30 +0000468 the optimal word tree (Polish, Italian and Hungarian
469 require several hundred Mbyte). The final result will
470 be much smaller, because compression is used. To
471 avoid running out of memory compression will be done
472 now and then. This can be tuned with the 'mkspellmem'
473 option.
Bram Moolenaar30abd282005-06-22 22:35:10 +0000474
Bram Moolenaard042c562005-06-30 22:04:15 +0000475 After the spell file was written and it was being used
476 in a buffer it will be reloaded automatically.
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000477
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000478:mksp[ell] [-ascii] {name}.{enc}.add
479 Like ":mkspell" above, using {name}.{enc}.add as the
Bram Moolenaard042c562005-06-30 22:04:15 +0000480 input file and producing an output file in the same
481 directory that has ".spl" appended.
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000482
483:mksp[ell] [-ascii] {name}
484 Like ":mkspell" above, using {name} as the input file
Bram Moolenaard042c562005-06-30 22:04:15 +0000485 and producing an output file in the same directory
486 that has ".{enc}.spl" appended.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000487
Bram Moolenaarae5bce12005-08-15 21:41:48 +0000488Vim will report the number of duplicate words. This might be a mistake in the
489list of words. But sometimes it is used to have different prefixes and
490suffixes for the same basic word to avoid them combining (e.g. Czech uses
Bram Moolenaar8aff23a2005-08-19 20:40:30 +0000491this). If you want Vim to report all duplicate words set the 'verbose'
492option.
Bram Moolenaarae5bce12005-08-15 21:41:48 +0000493
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000494Since you might want to change a Myspell word list for use with Vim the
495following procedure is recommended:
Bram Moolenaar217ad922005-03-20 22:37:15 +0000496
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00004971. Obtain the xx_YY.aff and xx_YY.dic files from Myspell.
4982. Make a copy of these files to xx_YY.orig.aff and xx_YY.orig.dic.
4993. Change the xx_YY.aff and xx_YY.dic files to remove bad words, add missing
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000500 words, define word characters with FOL/LOW/UPP, etc. The distributed
501 "src/spell/*.diff" files can be used.
Bram Moolenaard042c562005-06-30 22:04:15 +00005024. Start Vim with the right locale and use |:mkspell| to generate the Vim
503 spell file.
5045. Try out the spell file with ":set spell spelllang=xx" if you wrote it in
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +0000505 a spell directory in 'runtimepath', or ":set spelllang=xx.enc.spl" if you
Bram Moolenaard042c562005-06-30 22:04:15 +0000506 wrote it somewhere else.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000507
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000508When the Myspell files are updated you can merge the differences:
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00005091. Obtain the new Myspell files as xx_YY.new.aff and xx_UU.new.dic.
5102. Use Vimdiff to see what changed: >
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000511 vimdiff xx_YY.orig.dic xx_YY.new.dic
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00005123. Take over the changes you like in xx_YY.dic.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000513 You may also need to change xx_YY.aff.
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00005144. 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 +0000515
Bram Moolenaar3b506942005-06-23 22:36:45 +0000516
Bram Moolenaar8aff23a2005-08-19 20:40:30 +0000517SPELL FILE VERSIONS *E770* *E771* *E772*
518
519Spell checking is a relatively new feature in Vim, thus it's possible that the
520.spl file format will be changed to support more languages. Vim will check
521the validity of the spell file and report anything wrong.
522
523 E771: Old spell file, needs to be updated ~
524This spell file is older than your Vim. You need to update the .spl file.
525
526 E772: Spell file is for newer version of Vim ~
527This means the spell file was made for a later version of Vim. You need to
528update Vim.
529
530 E770: Unsupported section in spell file ~
531This means the spell file was made for a later version of Vim and contains a
532section that is required for the spell file to work. In this case it's
533probably a good idea to upgrade your Vim.
534
535
Bram Moolenaar3b506942005-06-23 22:36:45 +0000536SPELL FILE DUMP
537
538If for some reason you want to check what words are supported by the currently
539used spelling files, use this command:
540
541 *:spelldump* *:spelld*
542:spelld[ump] Open a new window and fill it with all currently valid
Bram Moolenaarac6e65f2005-08-29 22:25:38 +0000543 words. Compound words are not included.
Bram Moolenaard042c562005-06-30 22:04:15 +0000544 Note: For some languages the result may be enormous,
545 causing Vim to run out of memory.
Bram Moolenaar3b506942005-06-23 22:36:45 +0000546
Bram Moolenaar4770d092006-01-12 23:22:24 +0000547:spelld[ump]! Like ":spelldump" and include the word count. This is
548 the number of times the word was found while
549 updating the screen. Words that are in COMMON items
550 get a starting count of 10.
551
Bram Moolenaar3b506942005-06-23 22:36:45 +0000552The format of the word list is used |spell-wordlist-format|. You should be
553able to read it with ":mkspell" to generate one .spl file that includes all
554the words.
555
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000556When all entries to 'spelllang' use the same regions or no regions at all then
557the region information is included in the dumped words. Otherwise only words
558for the current region are included and no "/regions" line is generated.
Bram Moolenaar3b506942005-06-23 22:36:45 +0000559
Bram Moolenaard042c562005-06-30 22:04:15 +0000560Comment lines with the name of the .spl file are used as a header above the
561words that were generated from that .spl file.
Bram Moolenaar3b506942005-06-23 22:36:45 +0000562
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000563==============================================================================
Bram Moolenaard042c562005-06-30 22:04:15 +00005644. Spell file format *spell-file-format*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000565
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000566This is the format of the files that are used by the person who creates and
567maintains a word list.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000568
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000569Note that we avoid the word "dictionary" here. That is because the goal of
570spell checking differs from writing a dictionary (as in the book). For
Bram Moolenaar16d8f872005-11-26 23:46:11 +0000571spelling we need a list of words that are OK, thus should not be highlighted.
572Person and company names will not appear in a dictionary, but do appear in a
573word list. And some old words are rarely used while they are common
574misspellings. These do appear in a dictionary but not in a word list.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000575
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +0000576There are two formats: A straight list of words and a list using affix
Bram Moolenaard042c562005-06-30 22:04:15 +0000577compression. The files with affix compression are used by Myspell (Mozilla
578and OpenOffice.org). This requires two files, one with .aff and one with .dic
579extension.
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000580
581
Bram Moolenaard042c562005-06-30 22:04:15 +0000582FORMAT OF STRAIGHT WORD LIST *spell-wordlist-format*
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000583
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000584The words must appear one per line. That is all that is required.
Bram Moolenaard042c562005-06-30 22:04:15 +0000585
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000586Additionally the following items are recognized:
Bram Moolenaard042c562005-06-30 22:04:15 +0000587
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000588- Empty and blank lines are ignored.
Bram Moolenaard042c562005-06-30 22:04:15 +0000589
Bram Moolenaar4770d092006-01-12 23:22:24 +0000590 # comment ~
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000591- Lines starting with a # are ignored (comment lines).
Bram Moolenaard042c562005-06-30 22:04:15 +0000592
Bram Moolenaar4770d092006-01-12 23:22:24 +0000593 /encoding=utf-8 ~
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000594- A line starting with "/encoding=", before any word, specifies the encoding
595 of the file. After the second '=' comes an encoding name. This tells Vim
Bram Moolenaard042c562005-06-30 22:04:15 +0000596 to setup conversion from the specified encoding to 'encoding'. Thus you can
597 use one word list for several target encodings.
598
Bram Moolenaar4770d092006-01-12 23:22:24 +0000599 /regions=usca ~
Bram Moolenaar3638c682005-06-08 22:05:14 +0000600- A line starting with "/regions=" specifies the region names that are
601 supported. Each region name must be two ASCII letters. The first one is
602 region 1. Thus "/regions=usca" has region 1 "us" and region 2 "ca".
Bram Moolenaard042c562005-06-30 22:04:15 +0000603 In an addition word list the region names should be equal to the main word
604 list!
605
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000606- Other lines starting with '/' are reserved for future use. The ones that
Bram Moolenaar4770d092006-01-12 23:22:24 +0000607 are not recognized are ignored. You do get a warning message, so that you
608 know something won't work.
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000609
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000610- A "/" may follow the word with the following items:
611 = Case must match exactly.
612 ? Rare word.
613 ! Bad (wrong) word.
614 digit A region in which the word is valid. If no regions are
615 specified the word is valid in all regions.
616
Bram Moolenaar3638c682005-06-08 22:05:14 +0000617Example:
618
619 # This is an example word list comment
620 /encoding=latin1 encoding of the file
621 /regions=uscagb regions "us", "ca" and "gb"
622 example word for all regions
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000623 blah/12 word for regions "us" and "ca"
624 vim/! bad word
625 Campbell/?3 rare word in region 3 "gb"
626 's mornings/= keep-case word
Bram Moolenaar3638c682005-06-08 22:05:14 +0000627
Bram Moolenaar0dc065e2005-07-04 22:49:24 +0000628Note that when "/=" is used the same word with all upper-case letters is not
629accepted. This is different from a word with mixed case that is automatically
630marked as keep-case, those words may appear in all upper-case letters.
631
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000632
Bram Moolenaar4770d092006-01-12 23:22:24 +0000633FORMAT WITH .AFF and .DIC FILES
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000634
Bram Moolenaar4770d092006-01-12 23:22:24 +0000635There are two files: the basic word list and an affix file. The affix file
636specifies settings for the language and can contain affixes. The affixes are
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000637used to modify the basic words to get the full word list. This significantly
638reduces the number of words, especially for a language like Polish. This is
639called affix compression.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000640
Bram Moolenaar4770d092006-01-12 23:22:24 +0000641The basic word list and the affix file are combined with the ":mkspell"
642command and results in a binary spell file. All the preprocessing has been
643done, thus this file loads fast. The binary spell file format is described in
644the source code (src/spell.c). But only developers need to know about it.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000645
646The preprocessing also allows us to take the Myspell language files and modify
647them before the Vim word list is made. The tools for this can be found in the
648"src/spell" directory.
649
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000650The format for the affix and word list files is based on what Myspell uses
651(the spell checker of Mozilla and OpenOffice.org). A description can be found
652here:
653 http://lingucomponent.openoffice.org/affix.readme ~
654Note that affixes are case sensitive, this isn't obvious from the description.
655
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000656Vim supports quite a few extras. They are described below |spell-affix-vim|.
657Attempts have been made to keep this compatible with other spell checkers, so
Bram Moolenaar4770d092006-01-12 23:22:24 +0000658that the same files can often be used. One other project that offers more
659than Myspell is Hunspell ( http://hunspell.sf.net ).
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000660
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000661
Bram Moolenaar3638c682005-06-08 22:05:14 +0000662WORD LIST FORMAT *spell-dic-format*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000663
Bram Moolenaar4770d092006-01-12 23:22:24 +0000664A short example, with line numbers:
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000665
Bram Moolenaar4770d092006-01-12 23:22:24 +0000666 1 1234 ~
667 2 aan ~
668 3 Als ~
669 4 Etten-Leur ~
670 5 et al. ~
671 6 's-Gravenhage ~
672 7 's-Gravenhaags ~
673 8 # word that differs between regions ~
674 9 kado/1 ~
675 10 cadeau/2 ~
676 11 TCP,IP ~
677 12 /the S affix may add a 's' ~
678 13 bedel/S ~
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000679
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000680The first line contains the number of words. Vim ignores it, but you do get
681an error message if it's not there. *E760*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000682
Bram Moolenaar4770d092006-01-12 23:22:24 +0000683What follows is one word per line. White space at the end of the line is
684ignored, all other white space matters. The encoding is specified in the
685affix file |spell-SET|.
686
687Comment lines start with '#' or '/'. See the example lines 8 and 12. Note
688that putting a comment after a word is NOT allowed:
689
690 someword # comment that causes an error! ~
691
692After the word there is an optional slash and flags. Most of these flags are
693letters that indicate the affixes that can be used with this word. These are
694specified with SFX and PFX lines in the .aff file, see |spell-SFX| and
695|spell-PFX|. Vim allows using other flag types with the FLAG item in the
696affix file |spell-FLAG|.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000697
698When the word only has lower-case letters it will also match with the word
699starting with an upper-case letter.
700
701When the word includes an upper-case letter, this means the upper-case letter
702is required at this position. The same word with a lower-case letter at this
703position will not match. When some of the other letters are upper-case it will
704not match either.
705
Bram Moolenaar4770d092006-01-12 23:22:24 +0000706The word with all upper-case characters will always be OK,
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000707
708 word list matches does not match ~
709 als als Als ALS ALs AlS aLs aLS
710 Als Als ALS als ALs AlS aLs aLS
711 ALS ALS als Als ALs AlS aLs aLS
712 AlS AlS ALS als Als ALs aLs aLS
713
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +0000714The KEEPCASE affix ID can be used to specifically match a word with identical
715case only, see below |spell-KEEPCASE|.
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000716
Bram Moolenaar4770d092006-01-12 23:22:24 +0000717Note: in line 5 to 7 non-word characters are used. You can include any
718character in a word. When checking the text a word still only matches when it
719appears with a non-word character before and after it. For Myspell a word
720starting with a non-word character probably won't work.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000721
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000722In line 12 the word "TCP/IP" is defined. Since the slash has a special
723meaning the comma is used instead. This is defined with the SLASH item in the
Bram Moolenaar4770d092006-01-12 23:22:24 +0000724affix file, see |spell-SLASH|. Note that without this SLASH item the word
725will be "TCP,IP".
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000726
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000727
Bram Moolenaar4770d092006-01-12 23:22:24 +0000728AFFIX FILE FORMAT *spell-aff-format* *spell-affix-vim*
Bram Moolenaar0dc065e2005-07-04 22:49:24 +0000729
Bram Moolenaar4770d092006-01-12 23:22:24 +0000730 *spell-affix-comment*
731Comment lines in the .aff file start with a '#':
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000732
Bram Moolenaar4770d092006-01-12 23:22:24 +0000733 # comment line ~
734
735With some items it's also possible to put a comment after it, but this isn't
736supported in general.
737
738
739ENCODING *spell-SET*
740
741The affix file can be in any encoding that is supported by "iconv". However,
742in some cases the current locale should also be set properly at the time
743|:mkspell| is invoked. Adding FOL/LOW/UPP lines removes this requirement
744|spell-FOL|.
745
746The encoding should be specified before anything where the encoding matters.
747The encoding applies both to the affix file and the dictionary file. It is
748done with a SET line:
749
750 SET utf-8 ~
751
752The encoding can be different from the value of the 'encoding' option at the
753time ":mkspell" is used. Vim will then convert everything to 'encoding' and
754generate a spell file for 'encoding'. If some of the used characters to not
755fit in 'encoding' you will get an error message.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000756 *spell-affix-mbyte*
Bram Moolenaar4770d092006-01-12 23:22:24 +0000757When using a multi-byte encoding it's possible to use more different affix
758flags. But Myspell doesn't support that, thus you may not want to use it
759anyway. For compatibility use an 8-bit encoding.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000760
Bram Moolenaare13305e2005-06-19 22:54:15 +0000761
762CHARACTER TABLES
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000763 *spell-affix-chars*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000764When using an 8-bit encoding the affix file should define what characters are
Bram Moolenaar4770d092006-01-12 23:22:24 +0000765word characters. This is because the system where ":mkspell" is used may not
766support a locale with this encoding and isalpha() won't work. For example
767when using "cp1250" on Unix.
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000768 *E761* *E762* *spell-FOL*
769 *spell-LOW* *spell-UPP*
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000770Three lines in the affix file are needed. Simplistic example:
771
Bram Moolenaare13305e2005-06-19 22:54:15 +0000772 FOL áëñ ~
773 LOW áëñ ~
774 UPP ÁËÑ ~
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000775
776All three lines must have exactly the same number of characters.
777
778The "FOL" line specifies the case-folded characters. These are used to
779compare words while ignoring case. For most encodings this is identical to
780the lower case line.
781
782The "LOW" line specifies the characters in lower-case. Mostly it's equal to
783the "FOL" line.
784
785The "UPP" line specifies the characters with upper-case. That is, a character
786is upper-case where it's different from the character at the same position in
787"FOL".
788
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000789An exception is made for the German sharp s ß. The upper-case version is
790"SS". In the FOL/LOW/UPP lines it should be included, so that it's recognized
791as a word character, but use the ß character in all three.
792
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000793ASCII characters should be omitted, Vim always handles these in the same way.
794When the encoding is UTF-8 no word characters need to be specified.
795
796 *E763*
Bram Moolenaar3b506942005-06-23 22:36:45 +0000797Vim allows you to use spell checking for several languages in the same file.
798You can list them in the 'spelllang' option. As a consequence all spell files
799for the same encoding must use the same word characters, otherwise they can't
800be combined without errors. If you get a warning that the word tables differ
801you may need to generate the .spl file again with |:mkspell|. Check the FOL,
802LOW and UPP lines in the used .aff file.
803
804The XX.ascii.spl spell file generated with the "-ascii" argument will not
805contain the table with characters, so that it can be combine with spell files
806for any encoding. The .add.spl files also do not contain the table.
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000807
Bram Moolenaare7566042005-06-17 22:00:15 +0000808
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000809MID-WORD CHARACTERS
810 *spell-midword*
811Some characters are only to be considered word characters if they are used in
812between two ordinary word characters. An example is the single quote: It is
813often used to put text in quotes, thus it can't be recognized as a word
814character, but when it appears in between word characters it must be part of
815the word. This is needed to detect a spelling error such as they'are. That
816should be they're, but since "they" and "are" are words themselves that would
817go unnoticed.
818
Bram Moolenaar4770d092006-01-12 23:22:24 +0000819These characters are defined with MIDWORD in the .aff file. Example:
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000820
821 MIDWORD '- ~
822
823
Bram Moolenaar6e7c7f32005-08-24 22:16:11 +0000824FLAG TYPES *spell-FLAG*
825
826Flags are used to specify the affixes that can be used with a word and for
827other properties of the word. Normally single-character flags are used. This
828limits the number of possible flags, especially for 8-bit encodings. The FLAG
829item can be used if more affixes are to be used. Possible values:
830
831 FLAG long use two-character flags
832 FLAG num use numbers, from 1 up to 65000
Bram Moolenaar81f1ecb2005-08-25 21:27:31 +0000833 FLAG caplong use one-character flags without A-Z and two-character
Bram Moolenaar6e7c7f32005-08-24 22:16:11 +0000834 flags that start with A-Z
835
836With "FLAG num" the numbers in a list of affixes need to be separated with a
837comma: "234,2143,1435". This method is inefficient, but useful if the file is
838generated with a program.
839
Bram Moolenaar81f1ecb2005-08-25 21:27:31 +0000840When using "caplong" the two-character flags all start with a capital: "Aa",
841"B1", "BB", etc. This is useful to use one-character flags for the most
842common items and two-character flags for uncommon items.
Bram Moolenaar6e7c7f32005-08-24 22:16:11 +0000843
844Note: When using utf-8 only characters up to 65000 may be used for flags.
845
846
Bram Moolenaare13305e2005-06-19 22:54:15 +0000847AFFIXES
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000848 *spell-PFX* *spell-SFX*
Bram Moolenaare13305e2005-06-19 22:54:15 +0000849The usual PFX (prefix) and SFX (suffix) lines are supported (see the Myspell
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000850documentation or the Aspell manual:
851http://aspell.net/man-html/Affix-Compression.html).
Bram Moolenaare13305e2005-06-19 22:54:15 +0000852
Bram Moolenaar4770d092006-01-12 23:22:24 +0000853Summary:
854 SFX L Y 2 ~
855 SFX L 0 re [^x] ~
856 SFX L 0 ro x ~
857
858The first line is a header and has four fields:
859 SFX {flag} {combine} {count}
860
861{flag} The name used for the suffix. Mostly it's a single letter,
862 but other characters can be used, see |spell-FLAG|.
863
864{combine} Can be 'Y' or 'N'. When 'Y' then the word plus suffix can
865 also have a prefix. When 'N' then a prefix is not allowed.
866
867{count} The number of lines following. If this is wrong you will get
868 an error message.
869
870For PFX the fields are exactly the same.
871
872The basic format for the following lines is:
873 SFX {flag} {strip} {add} {condition}
874
875{flag} Must be the same as the {flag} used in the first line.
876
877{strip} Characters removed from the basic word. There is no check if
878 the characters are actually there, only the length is used (in
879 bytes). This better match the {condition}, otherwise strange
880 things may happen. If the {strip} length is equal to or
881 longer than the basic word the suffix won't be used.
882 When {strip} is 0 (zero) then nothing is stripped.
883
884{add} Characters added to the basic word, after removing {strip}.
885
886{condition} A simplistic pattern. Only when this matches with a basic
887 word will the suffix be used for that word. This is normally
888 for using one suffix letter with different {add} and {strip}
889 fields for words with different endings.
890 When {condition} is a . (dot) there is no condition.
891 The pattern may contain:
892 - Literal characters.
893 - A set of characters in []. [abc] matches a, b and c.
894 A dash is allowed for a range [a-c], but this is
895 Vim-specific.
896 - A set of characters that starts with a ^, meaning the
897 complement of the specified characters. [^abc] matches any
898 character but a, b and c.
899
900For PFX the fields are the same, but the {strip}, {add} and {condition} apply
901to the start of the word.
902
903Note: Myspell ignores any extra text after the relevant info. Vim requires
904this text to start with a "#" so that mistakes don't go unnoticed. Example:
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000905
906 SFX F 0 in [^i]n # Spion > Spionin ~
907 SFX F 0 nen in # Bauerin > Bauerinnen ~
908
Bram Moolenaar81f1ecb2005-08-25 21:27:31 +0000909Apparently Myspell allows an affix name to appear more than once. Since this
910might also be a mistake, Vim checks for an extra "S". The affix files for
911Myspell that use this feature apparently have this flag. Example:
912
913 SFX a Y 1 S ~
914 SFX a 0 an . ~
915
916 SFX a Y 2 S ~
917 SFX a 0 en . ~
918 SFX a 0 on . ~
919
Bram Moolenaar4770d092006-01-12 23:22:24 +0000920
921AFFIX FLAGS *spell-affix-flags*
922
923This is a feature that comes from Hunspell: The affix may specify flags. This
924works similar to flags specified on a basic word. The flags apply to the
925basic word plus the affix. Example:
926
927 SFX S Y 1 ~
928 SFX S 0 s . ~
929
930 SFX A Y 1 ~
931 SFX A 0 able/S . ~
932
933When the dictionary file contains "drink/AS" then these words are possible:
934
935 drink
936 drinks uses S suffix
937 drinkable uses A suffix
938 drinkables uses A suffix and then S suffix
939
940Generally the flags of the suffix are added to the flags of the basic word,
941both are used for the word plus suffix. But the flags of the basic word are
942only used once for affixes, except that both one prefix and one suffix can be
943used when both support combining.
944
945Specifically, the affix flags can be used for:
946- Affixes on affixes, as in the example above.
947- Making the word with the affix rare, by using the |spell-RARE| flag.
948- Exclude the word with the affix from compounding, by using the
949 |spell-COMPOUNDFORBIDFLAG| flag.
950
951-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
952OLD STUFF
Bram Moolenaar8aff23a2005-08-19 20:40:30 +0000953 *spell-affix-rare*
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000954An extra item for Vim is the "rare" flag. It must come after the other
955fields, before a comment. When used then all words that use the affix will be
Bram Moolenaar4770d092006-01-12 23:22:24 +0000956marked as rare words. Examples:
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000957
958 PFX F 0 nene . rare ~
959 SFX F 0 oin n rare # hardly ever used ~
960
Bram Moolenaar4770d092006-01-12 23:22:24 +0000961However, if the word also appears as a good word in another way (e.g., in
962another region) it won't be marked as rare.
Bram Moolenaare13305e2005-06-19 22:54:15 +0000963
Bram Moolenaar8aff23a2005-08-19 20:40:30 +0000964 *spell-affix-nocomp*
965Another extra item for Vim is the "nocomp" flag. It must come after the other
Bram Moolenaar90915b52005-08-21 22:17:52 +0000966fields, before a comment. It can be either before or after "rare". When
967present then all words that use the affix will not be part of a compound word.
Bram Moolenaar8aff23a2005-08-19 20:40:30 +0000968Example:
969 affix file:
970 COMPOUNDFLAG c ~
971 SFX a Y 2 ~
972 SFX a 0 s . ~
973 SFX a 0 ize . nocomp ~
974 dictionary:
975 word/c ~
976 util/ac ~
977
978This allows for "wordutil" and "wordutils" but not "wordutilize".
Bram Moolenaar4770d092006-01-12 23:22:24 +0000979-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Bram Moolenaar8aff23a2005-08-19 20:40:30 +0000980
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000981 *spell-PFXPOSTPONE*
Bram Moolenaare13305e2005-06-19 22:54:15 +0000982When an affix file has very many prefixes that apply to many words it's not
983possible to build the whole word list in memory. This applies to Hebrew (a
984list with all words is over a Gbyte). In that case applying prefixes must be
985postponed. This makes spell checking slower. It is indicated by this keyword
986in the .aff file:
987
988 PFXPOSTPONE ~
989
990Only prefixes without a chop string can be postponed, prefixes with a chop
Bram Moolenaar78984f52005-08-01 07:19:10 +0000991string will still be included in the word list. An exception if the chop
992string is one character and equal to the last character of the added string,
993but in lower case. Thus when the chop string is used to allow the following
994word to start with an upper case letter.
Bram Moolenaare13305e2005-06-19 22:54:15 +0000995
Bram Moolenaarae5bce12005-08-15 21:41:48 +0000996
Bram Moolenaar6f16eb82005-08-23 21:02:42 +0000997WORDS WITH A SLASH *spell-SLASH*
Bram Moolenaarae5bce12005-08-15 21:41:48 +0000998
999The slash is used in the .dic file to separate the basic word from the affix
Bram Moolenaar33aec762006-01-22 23:30:12 +00001000letters and other flags. Unfortunately, this means you cannot use a slash in
1001a word. Thus "TCP/IP" is not a word but "TCP with the flags "IP". To include
1002a slash in the word put a backslash before it: "TCP\/IP". In the rare case
1003you want to use a backslash inside a word you need to use two backslashes.
1004Any other use of the backslash is reserved for future expansion.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001005
1006
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +00001007KEEP-CASE WORDS *spell-KEEPCASE*
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001008
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +00001009In the affix file a KEEPCASE line can be used to define the affix name used
1010for keep-case words. Example:
Bram Moolenaar45eeb132005-06-06 21:59:07 +00001011
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +00001012 KEEPCASE = ~
Bram Moolenaar45eeb132005-06-06 21:59:07 +00001013
Bram Moolenaar4770d092006-01-12 23:22:24 +00001014This flag is not supported by Myspell. It has the meaning that case matters.
1015This can be used if the word does not have the first letter in upper case at
1016the start of a sentence. Example:
1017
1018 word list matches does not match ~
1019 's morgens/= 's morgens 'S morgens 's Morgens 'S MORGENS
1020 's Morgens 's Morgens 'S MORGENS 'S morgens 's morgens
1021
1022The flag can also be used to avoid that the word matches when it is in all
1023upper-case letters.
Bram Moolenaar45eeb132005-06-06 21:59:07 +00001024
Bram Moolenaare13305e2005-06-19 22:54:15 +00001025
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +00001026RARE WORDS *spell-RARE*
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001027
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +00001028In the affix file a RARE line can be used to define the affix name used for
Bram Moolenaar45eeb132005-06-06 21:59:07 +00001029rare words. Example:
1030
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +00001031 RARE ? ~
Bram Moolenaar45eeb132005-06-06 21:59:07 +00001032
1033Rare words are highlighted differently from bad words. This is to be used for
1034words that are correct for the language, but are hardly ever used and could be
Bram Moolenaar30abd282005-06-22 22:35:10 +00001035a typing mistake anyway. When the same word is found as good it won't be
1036highlighted as rare.
1037
1038
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001039BAD WORDS *spell-BAD*
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001040
Bram Moolenaar30abd282005-06-22 22:35:10 +00001041In the affix file a BAD line can be used to define the affix name used for
1042bad words. Example:
1043
1044 BAD ! ~
1045
1046This can be used to exclude words that would otherwise be good. For example
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +00001047"the the" in the .dic file:
1048
1049 the the/! ~
1050
1051Once a word has been marked as bad it won't be undone by encountering the same
1052word as good.
Bram Moolenaar45eeb132005-06-06 21:59:07 +00001053
Bram Moolenaar4770d092006-01-12 23:22:24 +00001054The flag also applies to the word with affixes, thus this can be used to mark
1055a whole bunch of related words as bad.
1056
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001057 *spell-NEEDAFFIX*
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001058The NEEDAFFIX flag is used to require that a word is used with an affix. The
Bram Moolenaar4770d092006-01-12 23:22:24 +00001059word itself is not a good word (unless there is an empty affix). Example:
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001060
1061 NEEDAFFIX + ~
1062
Bram Moolenaar45eeb132005-06-06 21:59:07 +00001063
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001064COMPOUND WORDS *spell-compound*
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001065
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001066A compound word is a longer word made by concatenating words that appear in
1067the .dic file. To specify which words may be concatenated a character is
1068used. This character is put in the list of affixes after the word. We will
1069call this character a flag here. Obviously these flags must be different from
1070any affix IDs used.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001071
1072 *spell-COMPOUNDFLAG*
Bram Moolenaar4770d092006-01-12 23:22:24 +00001073The Myspell compatible method uses one flag, specified with COMPOUNDFLAG. All
1074words with this flag combine in any order. This means there is no control
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001075over which word comes first. Example:
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001076 COMPOUNDFLAG c ~
1077
1078 *spell-COMPOUNDFLAGS*
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001079A more advanced method to specify how compound words can be formed uses
1080multiple items with multiple flags. This is not compatible with Myspell 3.0.
1081Let's start with an example:
1082 COMPOUNDFLAGS c+ ~
1083 COMPOUNDFLAGS se ~
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001084
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001085The first line defines that words with the "c" flag can be concatenated in any
1086order. The second line defines compound words that are made of one word with
1087the "s" flag and one word with the "e" flag. With this dictionary:
1088 bork/c ~
1089 onion/s ~
1090 soup/e ~
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001091
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001092You can make these words:
1093 bork
1094 borkbork
1095 borkborkbork
1096 (etc.)
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001097 onion
1098 soup
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001099 onionsoup
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001100
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001101The COMPOUNDFLAGS item may appear multiple times. The argument is made out of
1102one or more groups, where each group can be:
1103 one flag e.g., c
1104 alternate flags inside [] e.g., [abc]
1105Optionally this may be followed by:
1106 * the group appears zero or more times, e.g., sm*e
1107 + the group appears one or more times, e.g., c+
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001108
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001109This is similar to the regexp pattern syntax (but not the same!). A few
1110examples with the sequence of word flags they require:
1111 COMPOUNDFLAGS x+ x xx xxx etc.
1112 COMPOUNDFLAGS yz yz
1113 COMPOUNDFLAGS x+z xz xxz xxxz etc.
1114 COMPOUNDFLAGS yx+ yx yxx yxxx etc.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001115
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001116 COMPOUNDFLAGS [abc]z az bz cz
1117 COMPOUNDFLAGS [abc]+z az aaz abaz bz baz bcbz cz caz cbaz etc.
1118 COMPOUNDFLAGS a[xyz]+ ax axx axyz ay ayx ayzz az azy azxy etc.
1119 COMPOUNDFLAGS sm*e se sme smme smmme etc.
1120 COMPOUNDFLAGS s[xyz]*e se sxe sxye sxyxe sye syze sze szye szyxe etc.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001121
Bram Moolenaara6c840d2005-08-22 22:59:46 +00001122A specific example: Allow a compound to be made of two words and a dash:
1123 In the .aff file:
1124 COMPOUNDFLAGS sde ~
1125 NEEDAFFIX x ~
1126 COMPOUNDMAX 3 ~
1127 COMPOUNDMIN 1 ~
1128 In the .dic file:
1129 start/s ~
1130 end/e ~
1131 -/xd ~
1132
1133This allows for the word "start-end", but not "startend".
1134
Bram Moolenaar4770d092006-01-12 23:22:24 +00001135 *spell-NEEDCOMPOUND*
1136The NEEDCOMPOUND flag is used to require that a word is used as part of a
1137compound word. The word itself is not a good word. Example:
1138
1139 NEEDCOMPOUND & ~
1140
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001141 *spell-COMPOUNDMIN*
Bram Moolenaarac6e65f2005-08-29 22:25:38 +00001142The minimal character length of a word used for compounding is specified with
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001143COMPOUNDMIN. Example:
1144 COMPOUNDMIN 5 ~
1145
Bram Moolenaarac6e65f2005-08-29 22:25:38 +00001146When omitted there is no minimal length. Obviously you could just leave out
1147the compound flag from short words instead, this feature is present for
1148compatibility with Myspell.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001149
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001150 *spell-COMPOUNDMAX*
1151The maximum number of words that can be concatenated into a compound word is
1152specified with COMPOUNDMAX. Example:
1153 COMPOUNDMAX 3 ~
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001154
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001155When omitted there is no maximum. It applies to all compound words.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001156
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001157To set a limit for words with specific flags make sure the items in
1158COMPOUNDFLAGS where they appear don't allow too many words.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001159
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001160 *spell-COMPOUNDSYLMAX*
1161The maximum number of syllables that a compound word may contain is specified
1162with COMPOUNDSYLMAX. Example:
1163 COMPOUNDSYLMAX 6 ~
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001164
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001165This has no effect if there is no SYLLABLE item. Without COMPOUNDSYLMAX there
1166is no limit on the number of syllables.
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001167
Bram Moolenaara6c840d2005-08-22 22:59:46 +00001168If both COMPOUNDMAX and COMPOUNDSYLMAX are defined, a compound word is
1169accepted if it fits one of the criteria, thus is either made from up to
1170COMPOUNDMAX words or contains up to COMPOUNDSYLMAX syllables.
1171
Bram Moolenaar4770d092006-01-12 23:22:24 +00001172 *spell-COMPOUNDFORBIDFLAG*
1173The COMPOUNDFORBIDFLAG specifies a flag that can be used on an affix. It
1174means that the word plus affix cannot be used in a compound word.
1175NOT IMPLEMENTED YET.
1176
1177 *spell-COMPOUNDPERMITFLAG*
1178The COMPOUNDPERMITFLAG specifies a flag that can be used on an affix. It
1179means that the word plus affix can also be used in a compound word in a way
1180where the affix ends up halfway the word.
1181NOT IMPLEMENTED YET.
1182
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001183 *spell-SYLLABLE*
1184The SYLLABLE item defines characters or character sequences that are used to
1185count the number of syllables in a word. Example:
1186 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 +00001187
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001188Before the first slash is the set of characters that are counted for one
1189syllable, also when repeated and mixed, until the next character that is not
1190in this set. After the slash come sequences of characters that are counted
1191for one syllable. These are preferred over using characters from the set.
1192With the example "ideeen" has three syllables, counted by "i", "ee" and "e".
1193
1194Only case-folded letters need to be included.
1195
1196Above another way to restrict compounding was mentioned above: adding "nocomp"
1197after an affix causes all words that are made with that affix not be be used
1198for compounding. |spell-affix-nocomp|
1199
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001200
1201UNLIMITED COMPOUNDING *spell-NOBREAK*
1202
1203For some languages, such as Thai, there is no space in between words. This
1204looks like all words are compounded. To specify this use the NOBREAK item in
1205the affix file, without arguments:
1206 NOBREAK ~
1207
1208Vim will try to figure out where one word ends and a next starts. When there
1209are spelling mistakes this may not be quite right.
1210
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001211>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
1212NOTE: The following has not been implemented yet, because there are no word
1213lists that support this.
1214> *spell-CMP*
1215> Sometimes it is necessary to change a word when concatenating it to another,
1216> by removing a few letters, inserting something or both. It can also be useful
1217> to restrict concatenation to words that match a pattern. For this purpose CMP
1218> items can be used. They look like this:
1219> CMP {flag} {flags} {strip} {strip2} {add} {cond} {cond2}
1220>
1221> {flag} the flag, as used in COMPOUNDFLAGS for the lead word
1222> {flags} accepted flags for the following word ('.' to accept
1223> all)
1224> {strip} text to remove from the end of the lead word (zero
1225> for no stripping)
1226> {strip2} text to remove from the start of the following word
1227> (zero for no stripping)
1228> {add} text to insert between the words (zero for no
1229> addition)
1230> {cond} condition to match at the end of the lead word
1231> {cond2} condition to match at the start of the following word
1232>
1233> This is the same as what is used for SFX and PFX items, with the extra {flags}
1234> and {cond2} fields. Example:
1235> CMP f mrt 0 - . . ~
1236>
1237> When used with the food and dish word list above, this means that a dash is
1238> inserted after each food item. Thus you get "onion-soup" and
1239> "onion-tomato-salat".
1240>
1241> When there are CMP items for a compound flag the concatenation is only done
1242> when a CMP item matches.
1243>
1244> When there are no CMP items for a compound flag, then all words will be
1245> concatenated, as if there was an item:
1246> CMP {flag} . 0 0 . .
1247>
1248>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Bram Moolenaarae5bce12005-08-15 21:41:48 +00001249
1250
Bram Moolenaar4770d092006-01-12 23:22:24 +00001251 *spell-COMMON*
1252Common words can be specified with the COMMON item. This will give better
1253suggestions when editing a short file. Example:
1254
1255 COMMON the of to and a in is it you that he was for on are ~
1256
1257The words must be separated by white space, up to 25 per line.
1258When multiple regions are specified in a ":mkspell" command the common words
1259for all regions are combined and used for all regions.
1260
1261 *spell-NOSPLITSUGS*
1262This item indicates that suggestions for splitting a word will not appear:
1263
1264 NOSPLITSUGS ~
1265
1266 *spell-NOSUGGEST*
1267The flag specified with NOSUGGEST can be used for words that will not be
1268suggested. Can be used for obscene words.
1269
1270 NOSUGGEST % ~
1271
1272NOT IMPLEMENTED YET.
1273
1274
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001275REPLACEMENTS *spell-REP*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001276
1277In the affix file REP items can be used to define common mistakes. This is
1278used to make spelling suggestions. The items define the "from" text and the
1279"to" replacement. Example:
1280
1281 REP 4 ~
1282 REP f ph ~
1283 REP ph f ~
1284 REP k ch ~
1285 REP ch k ~
1286
Bram Moolenaar6e7c7f32005-08-24 22:16:11 +00001287The first line specifies the number of REP lines following. Vim ignores the
Bram Moolenaar4770d092006-01-12 23:22:24 +00001288number, but it must be there (for compatibility with Myspell).
Bram Moolenaar6e7c7f32005-08-24 22:16:11 +00001289
Bram Moolenaard042c562005-06-30 22:04:15 +00001290Don't include simple one-character replacements or swaps. Vim will try these
1291anyway. You can include whole words if you want to, but you might want to use
1292the "file:" item in 'spellsuggest' instead.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001293
Bram Moolenaar1e015462005-09-25 22:16:38 +00001294You can include a space by using an underscore:
1295
1296 REP the_the the ~
1297
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001298
Bram Moolenaara40ceaf2006-01-13 22:35:40 +00001299SIMILAR CHARACTERS *spell-MAP* *E783*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001300
Bram Moolenaard042c562005-06-30 22:04:15 +00001301In the affix file MAP items can be used to define letters that are very much
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001302alike. This is mostly used for a letter with different accents. This is used
1303to prefer suggestions with these letters substituted. Example:
1304
1305 MAP 2 ~
1306 MAP eéëêè ~
1307 MAP uüùúû ~
1308
Bram Moolenaar6e7c7f32005-08-24 22:16:11 +00001309The first line specifies the number of MAP lines following. Vim ignores the
1310number, but the line must be there.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001311
Bram Moolenaard042c562005-06-30 22:04:15 +00001312Each letter must appear in only one of the MAP items. It's a bit more
1313efficient if the first letter is ASCII or at least one without accents.
Bram Moolenaare7566042005-06-17 22:00:15 +00001314
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001315
Bram Moolenaar4770d092006-01-12 23:22:24 +00001316.SUG FILE *spell-NOSUGFILE*
1317
1318When soundfolding is specified in the affix file then ":mkspell" will normally
Bram Moolenaard12f5c12006-01-25 22:10:52 +00001319produce a .sug file next to the .spl file. This file is used to find
1320suggestions by their sound-a-like form quickly. At the cost of a lot of
1321memory (the amount depends on the number of words, |:mkspell| will display an
1322estimate when it's done).
Bram Moolenaar4770d092006-01-12 23:22:24 +00001323
1324To avoid producing a .sug file use this item in the affix file:
1325
1326 NOSUGFILE ~
1327
Bram Moolenaard12f5c12006-01-25 22:10:52 +00001328Users can simply omit the .sug file if they don't want to use it.
1329
Bram Moolenaar4770d092006-01-12 23:22:24 +00001330
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001331SOUND-A-LIKE *spell-SAL*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001332
1333In the affix file SAL items can be used to define the sounds-a-like mechanism
1334to be used. The main items define the "from" text and the "to" replacement.
Bram Moolenaard042c562005-06-30 22:04:15 +00001335Simplistic example:
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001336
1337 SAL CIA X ~
1338 SAL CH X ~
1339 SAL C K ~
1340 SAL K K ~
1341
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +00001342There are a few rules and this can become quite complicated. An explanation
Bram Moolenaard042c562005-06-30 22:04:15 +00001343how it works can be found in the Aspell manual:
Bram Moolenaar42eeac32005-06-29 22:40:58 +00001344http://aspell.net/man-html/Phonetic-Code.html.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00001345
1346There are a few special items:
1347
1348 SAL followup true ~
1349 SAL collapse_result true ~
1350 SAL remove_accents true ~
1351
1352"1" has the same meaning as "true". Any other value means "false".
1353
Bram Moolenaar42eeac32005-06-29 22:40:58 +00001354
Bram Moolenaar6f16eb82005-08-23 21:02:42 +00001355SIMPLE SOUNDFOLDING *spell-SOFOFROM* *spell-SOFOTO*
Bram Moolenaar42eeac32005-06-29 22:40:58 +00001356
1357The SAL mechanism is complex and slow. A simpler mechanism is mapping all
1358characters to another character, mapping similar sounding characters to the
1359same character. At the same time this does case folding. You can not have
Bram Moolenaard042c562005-06-30 22:04:15 +00001360both SAL items and simple soundfolding.
Bram Moolenaar42eeac32005-06-29 22:40:58 +00001361
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +00001362There are two items required: one to specify the characters that are mapped
Bram Moolenaar42eeac32005-06-29 22:40:58 +00001363and one that specifies the characters they are mapped to. They must have
1364exactly the same number of characters. Example:
1365
1366 SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~
1367 SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkes ~
1368
1369In the example all vowels are mapped to the same character 'e'. Another
Bram Moolenaard042c562005-06-30 22:04:15 +00001370method would be to leave out all vowels. Some characters that sound nearly
1371the same and are often mixed up, such as 'm' and 'n', are mapped to the same
1372character. Don't do this too much, all words will start looking alike.
Bram Moolenaar42eeac32005-06-29 22:40:58 +00001373
1374Characters that do not appear in SOFOFROM will be left out, except that all
1375white space is replaced by one space. Sequences of the same character in
1376SOFOFROM are replaced by one.
1377
1378You can use the |soundfold()| function to try out the results. Or set the
Bram Moolenaarcc016f52005-12-10 20:23:46 +00001379'verbose' option to see the score in the output of the |z=| command.
Bram Moolenaar42eeac32005-06-29 22:40:58 +00001380
1381
Bram Moolenaar4770d092006-01-12 23:22:24 +00001382UNSUPPORTED ITEMS *spell-affix-not-supported*
1383
1384These items appear in the affix file of other spell checkers. In Vim they are
1385ignored, not supported or defined in another way.
1386
1387ACCENT (Hunspell) *spell-ACCENT*
1388 Use MAP instead. |spell-MAP|
1389
1390CHECKCOMPOUNDCASE (Hunspell) *spell-CHECKCOMPOUNDCASE*
1391 Disallow uppercase letters at compound word boundaries.
1392 Not supported.
1393
1394CHECKCOMPOUNDDUP (Hunspell) *spell-CHECKCOMPOUNDDUP*
1395 Disallow using the same word twice in a compound. Not
1396 supported.
1397
1398CHECKCOMPOUNDREP (Hunspell) *spell-CHECKCOMPOUNDREP*
1399 Something about using REP items and compound words. Not
1400 supported.
1401
1402CHECKCOMPOUNDTRIPLE (Hunspell) *spell-CHECKCOMPOUNDTRIPLE*
1403 Forbid three identical characters when compounding. Not
1404 supported.
1405
1406CHECKCOMPOUNDPATTERN (Hunspell) *spell-CHECKCOMPOUNDPATTERN*
1407 Forbid compounding when patterns match. Not supported.
1408
1409CIRCUMFIX (Hunspell) *spell-CIRCUMFIX*
1410 This means a prefix and suffix must be added at the same time.
1411 Instead only specify the suffix, and give the that suffix two
1412 flags: The required prefix and the NEEDAFFIX flag.
1413 |spell-NEEDAFFIX|
1414
1415COMPLEXPREFIXES (Hunspell) *spell-COMPLEXPREFIXES*
1416 Enables using two prefixes. Not supported.
1417
1418COMPOUNDBEGIN (Hunspell) *spell-COMPOUNDBEGIN*
1419 Use COMPOUNDFLAGS instead. |spell-COMPOUNDFLAGS|
1420
1421COMPOUNDEND (Hunspell) *spell-COMPOUNDEND*
1422 Use COMPOUNDFLAGS instead. |spell-COMPOUNDFLAGS|
1423
1424COMPOUNDMIDDLE (Hunspell) *spell-COMPOUNDMIDDLE*
1425 Use COMPOUNDFLAGS instead. |spell-COMPOUNDFLAGS|
1426
1427COMPOUNDROOT (Hunspell) *spell-COMPOUNDROOT*
1428 Flag for words in the dictionary that are already a compound.
1429 Vim doesn't use it.
1430
1431COMPOUNDSYLLABLE (Hunspell) *spell-COMPOUNDSYLLABLE*
1432 Use SYLLABLE and COMPOUNDSYLMAX instead. |spell-SYLLABLE|
1433 |spell-COMPOUNDSYLMAX|
1434
1435COMPOUNDWORDMAX (Hunspell) *spell-COMPOUNDWORDMAX*
1436 Use COMPOUNDMAX instead. |spell-COMPOUNDMAX|
1437
1438FORBIDDENWORD (Hunspell) *spell-FORBIDDENWORD*
1439 Use BAD instead. |spell-BAD|
1440
1441HOME (Hunspell) *spell-HOME*
1442 Specifies the website for the language. Not supported.
1443
1444LANG (Hunspell) *spell-LANG*
1445 This specifies language-specific behavior. This actually
1446 moves part of the language knowledge into the program,
1447 therefore Vim does not support it. Each language property
1448 must be specified separately.
1449
1450LEMMA_PRESENT (Hunspell) *spell-LEMMA_PRESENT*
1451 Only needed for mprphological analysis.
1452
1453MAXNGRAMSUGS (Hunspell) *spell-MAXNGRAMSUGS*
1454 Not supported.
1455
1456NAME (Hunspell) *spell-NAME*
1457 Specifies the name of the language. Not supported.
1458
1459ONLYINCOMPOUND (Hunspell) *spell-ONLYINCOMPOUND*
1460 Use NEEDCOMPOUND instead. |spell-NEEDCOMPOUND|
1461
1462PSEUDOROOT (Hunspell) *spell-PSEUDOROOT*
1463 Use NEEDAFFIX instead. |spell-NEEDAFFIX|
1464
1465SUGSWITHDOTS (Hunspell) *spell-SUGSWITHDOTS*
1466 Adds dots to suggestions. Vim doesn't need this.
1467
1468SYLLABLENUM (Hunspell) *spell-SYLLABLENUM*
1469 Not supported.
1470
1471TRY (Myspell, Hunspell, others) *spell-TRY*
1472 Vim does not use the TRY item, it is ignored. For making
1473 suggestions the actual characters in the words are used.
1474
1475VERSION (Hunspell) *spell-VERSION*
1476 Specifies the version for the language. Not supported.
1477
1478WORDCHARS (Hunspell) *spell-WORDCHARS*
1479 Used to recognize words. Vim doesn't need it, because there
1480 is no need to separate words before checking them (using a
1481 trie instead of a hashtable).
1482
Bram Moolenaar217ad922005-03-20 22:37:15 +00001483 vim:tw=78:sw=4:ts=8:ft=help:norl: