blob: 46d1b70dae52af613419044e31b8e8187d837fab [file] [log] [blame]
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +00001*spell.txt* For Vim version 7.0aa. Last change: 2005 Jul 03
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
36To search for the next misspelled word:
37
38 *]s* *E756*
39]s Move to next misspelled word after the cursor.
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +000040 A count before the command can be used to repeat.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +000041
42 *[s*
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +000043[s Like "]s" but search backwards, find the misspelled
Bram Moolenaar30abd282005-06-22 22:35:10 +000044 word before the cursor. Doesn't recognize words
45 split over two lines, thus may stop at words that are
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000046 not highlighted as bad. Does not stop at word with
47 missing capital at the start of a line.
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +000048
49 *]S*
50]S Like "]s" but only stop at bad words, not at rare
51 words or words for another region.
52
53 *[S*
54[S Like "]S" but search backwards.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +000055
Bram Moolenaar217ad922005-03-20 22:37:15 +000056
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +000057To add words to your own word list: *E764*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000058
59 *zg*
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000060zg Add word under the cursor as a good word to the first
61 name in 'spellfile'. In Visual mode the selected
62 characters are added as a word (including white
63 space!). If the word is explicitly marked as bad word
64 in another spell file the result is unpredictable.
65 A count may precede the command to indicate the entry
66 in 'spellfile' to be used. A count of two uses the
67 second entry.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000068
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000069 *zG*
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000070zG Like "zg" but add the word to the internal word list
71 |internal-wordlist|.
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000072
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000073 *zw*
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000074zw Like "zg" but mark the word as a wrong (bad) word.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000075
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000076 *zW*
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000077zW Like "zw" but add the word to the internal word list
78 |internal-wordlist|.
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000079
Bram Moolenaar520470a2005-06-16 21:59:56 +000080 *:spe* *:spellgood*
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000081:[count]spe[llgood] {word}
82 Add [word} as a good word to 'spellfile', like with
83 "zg". Without count the first name is used, with a
84 count of two the second entry, etc.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000085
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000086:spe[llgood]! {word} Add [word} as a good word to the internal word list,
87 like with "zG".
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000088
Bram Moolenaar520470a2005-06-16 21:59:56 +000089 *:spellw* *:spellwrong*
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +000090:[count]spellw[rong] {word}
91 Add [word} as a wrong (bad) word to 'spellfile', as
92 with "zw". Without count the first name is used, with
93 a count of two the second entry, etc.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +000094
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +000095:spellw[rong]! {word} Add [word} as a wrong (bad) word to the internal word
96 list.
97
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000098After adding a word to 'spellfile' with the above commands its associated
Bram Moolenaard042c562005-06-30 22:04:15 +000099".spl" file will automatically be updated and reloaded. If you change
100'spellfile' manually you need to use the |:mkspell| command. This sequence of
101commands mostly works well: >
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000102 :edit <file in 'spellfile'>
Bram Moolenaarf461c8e2005-06-25 23:04:51 +0000103< (make changes to the spell file) >
104 :mkspell! %
105
106More details about the 'spellfile' format below |spell-wordlist-format|.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000107
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000108 *internal-wordlist*
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000109The internal word list is used for all buffers where 'spell' is set. It is
110not stored, it is lost when you exit Vim. It is also cleared when 'encoding'
111is set.
112
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000113
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000114Finding suggestions for bad words:
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000115 *z?*
Bram Moolenaar30abd282005-06-22 22:35:10 +0000116z? For the word under/after the cursor suggest correctly
Bram Moolenaard042c562005-06-30 22:04:15 +0000117 spelled words. This also works to find alternatives
118 for a word that is not highlighted as a bad word,
119 e.g., when the word after it is bad.
Bram Moolenaar30abd282005-06-22 22:35:10 +0000120 The results are sorted on similarity to the word
121 under/after the cursor.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000122 This may take a long time. Hit CTRL-C when you are
123 bored.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +0000124 This does not work when there is a line break halfway
125 a bad word (e.g., "the the").
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000126 You can enter the number of your choice or press
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +0000127 <Enter> if you don't want to replace. You can also
128 use the mouse to click on your choice (only works if
129 the mouse can be used in Normal mode and when there
Bram Moolenaard042c562005-06-30 22:04:15 +0000130 are no line wraps). Click on the first (header) line
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +0000131 to cancel.
Bram Moolenaarf3bd51a2005-06-14 22:11:18 +0000132 If 'verbose' is non-zero a score will be displayed to
133 indicate the likeliness to the badly spelled word (the
134 higher the score the more different).
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000135 When a word was replaced the redo command "." will
136 repeat the word replacement. This works like "ciw",
137 the good word and <Esc>.
138
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +0000139 *:spellr* *:spellrepall* *E752* *E753*
140:spellr[epall] Repeat the replacement done by |z?| for all matches
141 with the replaced word in the current window.
142
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000143The 'spellsuggest' option influences how the list of suggestions is generated
144and sorted. See |'spellsuggest'|.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000145
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000146The 'spellcapcheck' option is used to check the first word of a sentence
147starts with a capital. This doesn't work for the first word in the file.
148When there is a line break right after a sentence the highlighting of the next
149line may be postponed. Use |CTRL-L| when needed.
150
Bram Moolenaard042c562005-06-30 22:04:15 +0000151==============================================================================
1522. Remarks on spell checking *spell-remarks*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000153
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000154PERFORMANCE
155
Bram Moolenaard042c562005-06-30 22:04:15 +0000156Vim does on-the-fly spell checking. To make this work fast the word list is
157loaded in memory. Thus this uses a lot of memory (1 Mbyte or more). There
158might also be a noticeable delay when the word list is loaded, which happens
159when 'spell' is set and when 'spelllang' is set while 'spell' was already set.
160To minimize the delay each word list is only loaded once, it is not deleted
161when 'spelllang' is made empty or 'spell' is reset. When 'encoding' is set
162all the word lists are reloaded, thus you may notice a delay then too.
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000163
164
Bram Moolenaar217ad922005-03-20 22:37:15 +0000165REGIONS
166
167A word may be spelled differently in various regions. For example, English
168comes in (at least) these variants:
169
170 en all regions
Bram Moolenaar5c5474b2005-04-19 21:40:26 +0000171 en_au Australia
Bram Moolenaar217ad922005-03-20 22:37:15 +0000172 en_ca Canada
Bram Moolenaar5c5474b2005-04-19 21:40:26 +0000173 en_gb Great Britain
174 en_nz New Zealand
175 en_us USA
Bram Moolenaar217ad922005-03-20 22:37:15 +0000176
177Words that are not used in one region but are used in another region are
Bram Moolenaar520470a2005-06-16 21:59:56 +0000178highlighted with SpellLocal |hl-SpellLocal|.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000179
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000180Always use lowercase letters for the language and region names.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000181
Bram Moolenaar3638c682005-06-08 22:05:14 +0000182When adding a word with |zg| or another command it's always added for all
183regions. You can change that by manually editing the 'spellfile'. See
184|spell-wordlist-format|.
185
Bram Moolenaar217ad922005-03-20 22:37:15 +0000186
Bram Moolenaar3b506942005-06-23 22:36:45 +0000187SPELL FILES *spell-load*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000188
189Vim searches for spell files in the "spell" subdirectory of the directories in
Bram Moolenaar3638c682005-06-08 22:05:14 +0000190'runtimepath'. The name is: LL.EEE.spl, where:
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000191 LL the language name
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000192 EEE the value of 'encoding'
Bram Moolenaar217ad922005-03-20 22:37:15 +0000193
Bram Moolenaar3b506942005-06-23 22:36:45 +0000194The value for "LL" comes from 'spelllang', but excludes the region name.
195Examples:
196 'spelllang' LL ~
197 en_us en
198 en-rare en-rare
199 medical_ca medical
200
Bram Moolenaar3638c682005-06-08 22:05:14 +0000201Only the first file is loaded, the one that is first in 'runtimepath'. If
202this succeeds then additionally files with the name LL.EEE.add.spl are loaded.
203All the ones that are found are used.
204
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000205Additionally, the files related to the names in 'spellfile' are loaded. These
206are the files that |zg| and |zw| add good and wrong words to.
Bram Moolenaar3b506942005-06-23 22:36:45 +0000207
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000208Exceptions:
209- Vim uses "latin1" when 'encoding' is "iso-8859-15". The euro sign doesn't
210 matter for spelling.
211- When no spell file for 'encoding' is found "ascii" is tried. This only
212 works for languages where nearly all words are ASCII, such as English. It
213 helps when 'encoding' is not "latin1", such as iso-8859-2, and English text
Bram Moolenaar3638c682005-06-08 22:05:14 +0000214 is being edited. For the ".add" files the same name as the found main
215 spell file is used.
216
217For example, with these values:
218 'runtimepath' is "~/.vim,/usr/share/vim70,~/.vim/after"
219 'encoding' is "iso-8859-2"
220 'spelllang' is "pl"
221
222Vim will look for:
2231. ~/.vim/spell/pl.iso-8859-2.spl
2242. /usr/share/vim70/spell/pl.iso-8859-2.spl
2253. ~/.vim/spell/pl.iso-8859-2.add.spl
2264. /usr/share/vim70/spell/pl.iso-8859-2.add.spl
2275. ~/.vim/after/spell/pl.iso-8859-2.add.spl
228
229This assumes 1. is not found and 2. is found.
230
231If 'encoding' is "latin1" Vim will look for:
2321. ~/.vim/spell/pl.latin1.spl
2332. /usr/share/vim70/spell/pl.latin1.spl
2343. ~/.vim/after/spell/pl.latin1.spl
2354. ~/.vim/spell/pl.ascii.spl
2365. /usr/share/vim70/spell/pl.ascii.spl
2376. ~/.vim/after/spell/pl.ascii.spl
238
239This assumes none of them are found (Polish doesn't make sense when leaving
240out the non-ASCII characters).
Bram Moolenaar217ad922005-03-20 22:37:15 +0000241
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000242Spelling for EBCDIC is currently not supported.
243
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000244A spell file might not be available in the current 'encoding'. See
245|spell-mkspell| about how to create a spell file. Converting a spell file
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000246with "iconv" will NOT work!
Bram Moolenaar217ad922005-03-20 22:37:15 +0000247
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000248 *E758* *E759*
249When loading a spell file Vim checks that it is properly formatted. If you
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000250get an error the file may be truncated, modified or intended for another Vim
251version.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000252
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000253
254WORDS
255
256Vim uses a fixed method to recognize a word. This is independent of
257'iskeyword', so that it also works in help files and for languages that
258include characters like '-' in 'iskeyword'. The word characters do depend on
259'encoding'.
260
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000261The table with word characters is stored in the main .spl file. Therefore it
262matters what the current locale is when generating it! A .add.spl file does
Bram Moolenaarf461c8e2005-06-25 23:04:51 +0000263not contain a word table though.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000264
Bram Moolenaar3638c682005-06-08 22:05:14 +0000265A word that starts with a digit is always ignored. That includes hex numbers
266in the form 0xff and 0XFF.
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000267
268
Bram Moolenaar30abd282005-06-22 22:35:10 +0000269WORD COMBINATIONS
270
271It is possible to spell-check words that include a space. This is used to
272recognize words that are invalid when used by themselves, e.g. for "et al.".
273It can also be used to recognize "the the" and highlight it.
274
275The number of spaces is irrelevant. In most cases a line break may also
276appear. However, this makes it difficult to find out where to start checking
277for spelling mistakes. When you make a change to one line and only that line
278is redrawn Vim won't look in the previous line, thus when "et" is at the end
279of the previous line "al." will be flagged as an error. And when you type
280"the<CR>the" the highlighting doesn't appear until the first line is redrawn.
281Use |CTRL-L| to redraw right away. "[s" will also stop at a word combination
282with a line break.
283
284When encountering a line break Vim skips characters such as '*', '>' and '"',
285so that comments in C, shell and Vim code can be spell checked.
286
287
Bram Moolenaar9d0ec2e2005-04-20 19:45:58 +0000288SYNTAX HIGHLIGHTING *spell-syntax*
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000289
290Files that use syntax highlighting can specify where spell checking should be
291done:
292
Bram Moolenaar3638c682005-06-08 22:05:14 +00002931. everywhere default
2942. in specific items use "contains=@Spell"
2953. everywhere but specific items use "contains=@NoSpell"
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000296
Bram Moolenaar3638c682005-06-08 22:05:14 +0000297For the second method adding the @NoSpell cluster will disable spell checking
298again. This can be used, for example, to add @Spell to the comments of a
299program, and add @NoSpell for items that shouldn't be checked.
Bram Moolenaar6bb68362005-03-22 23:03:44 +0000300
Bram Moolenaar30abd282005-06-22 22:35:10 +0000301
302VIM SCRIPTS
303
304If you want to write a Vim script that does something with spelling, you may
305find these functions useful:
306
307 spellbadword() find badly spelled word at the cursor
308 spellsuggest() get list of spelling suggestions
Bram Moolenaard042c562005-06-30 22:04:15 +0000309 soundfold() get the sound-a-like version of a word
Bram Moolenaar30abd282005-06-22 22:35:10 +0000310
Bram Moolenaar217ad922005-03-20 22:37:15 +0000311==============================================================================
Bram Moolenaard042c562005-06-30 22:04:15 +00003123. Generating a spell file *spell-mkspell*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000313
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000314Vim uses a binary file format for spelling. This greatly speeds up loading
315the word list and keeps it small.
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000316 *.aff* *.dic* *Myspell*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000317You can create a Vim spell file from the .aff and .dic files that Myspell
318uses. Myspell is used by OpenOffice.org and Mozilla. You should be able to
319find them here:
320 http://lingucomponent.openoffice.org/spell_dic.html
Bram Moolenaar30abd282005-06-22 22:35:10 +0000321You can also use a plain word list. The results are the same, the choice
Bram Moolenaard042c562005-06-30 22:04:15 +0000322depends on what word lists you can find.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000323
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +0000324If you install Aap (from www.a-a-p.org) you can use the recipes in the
325runtime/spell/??/ directories. Aap will take care of downloading the files,
326apply patches needed for Vim and build the .spl file.
327
Bram Moolenaare13305e2005-06-19 22:54:15 +0000328Make sure your current locale is set properly, otherwise Vim doesn't know what
329characters are upper/lower case letters. If the locale isn't available (e.g.,
330when using an MS-Windows codepage on Unix) add tables to the .aff file
Bram Moolenaar3b506942005-06-23 22:36:45 +0000331|spell-affix-chars|. If the .aff file doesn't define a table then the word
332table of the currently active spelling is used. If spelling is not active
333then Vim will try to guess.
Bram Moolenaare13305e2005-06-19 22:54:15 +0000334
Bram Moolenaar3b506942005-06-23 22:36:45 +0000335 *:mksp* *:mkspell*
336:mksp[ell][!] [-ascii] {outname} {inname} ...
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000337 Generate a Vim spell file word lists. Example: >
Bram Moolenaard042c562005-06-30 22:04:15 +0000338 :mkspell /tmp/nl nl_NL.words
Bram Moolenaar3b506942005-06-23 22:36:45 +0000339< *E751*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000340 When {outname} ends in ".spl" it is used as the output
341 file name. Otherwise it should be a language name,
Bram Moolenaar3b506942005-06-23 22:36:45 +0000342 such as "en", without the region name. The file
343 written will be "{outname}.{encoding}.spl", where
344 {encoding} is the value of the 'encoding' option.
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000345
Bram Moolenaard042c562005-06-30 22:04:15 +0000346 When the output file already exists [!] must be used
Bram Moolenaar520470a2005-06-16 21:59:56 +0000347 to overwrite it.
348
Bram Moolenaar0e21a3f2005-04-17 20:28:32 +0000349 When the [-ascii] argument is present, words with
350 non-ascii characters are skipped. The resulting file
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000351 ends in "ascii.spl".
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000352
353 The input can be the Myspell format files {inname}.aff
354 and {inname}.dic. If {inname}.aff does not exist then
355 {inname} is used as the file name of a plain word
356 list.
357
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000358 Multiple {inname} arguments can be given to combine
359 regions into one Vim spell file. Example: >
360 :mkspell ~/.vim/spell/en /tmp/en_US /tmp/en_CA /tmp/en_AU
361< This combines the English word lists for US, CA and AU
362 into one en.spl file.
363 Up to eight regions can be combined. *E754* *755*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000364 The REP and SAL items of the first .aff file where
365 they appear are used. |spell-affix-REP|
366 |spell-affix-SAL|
Bram Moolenaar217ad922005-03-20 22:37:15 +0000367
Bram Moolenaar30abd282005-06-22 22:35:10 +0000368 This command uses a lot of memory, required to find
369 the optimal word tree (Polish requires a few hundred
370 Mbyte). The final result will be much smaller.
371
Bram Moolenaard042c562005-06-30 22:04:15 +0000372 After the spell file was written and it was being used
373 in a buffer it will be reloaded automatically.
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000374
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000375:mksp[ell] [-ascii] {name}.{enc}.add
376 Like ":mkspell" above, using {name}.{enc}.add as the
Bram Moolenaard042c562005-06-30 22:04:15 +0000377 input file and producing an output file in the same
378 directory that has ".spl" appended.
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000379
380:mksp[ell] [-ascii] {name}
381 Like ":mkspell" above, using {name} as the input file
Bram Moolenaard042c562005-06-30 22:04:15 +0000382 and producing an output file in the same directory
383 that has ".{enc}.spl" appended.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000384
385Since you might want to change a Myspell word list for use with Vim the
386following procedure is recommended:
Bram Moolenaar217ad922005-03-20 22:37:15 +0000387
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00003881. Obtain the xx_YY.aff and xx_YY.dic files from Myspell.
3892. Make a copy of these files to xx_YY.orig.aff and xx_YY.orig.dic.
3903. Change the xx_YY.aff and xx_YY.dic files to remove bad words, add missing
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000391 words, define word characters with FOL/LOW/UPP, etc. The distributed
392 "src/spell/*.diff" files can be used.
Bram Moolenaard042c562005-06-30 22:04:15 +00003934. Start Vim with the right locale and use |:mkspell| to generate the Vim
394 spell file.
3955. Try out the spell file with ":set spell spelllang=xx" if you wrote it in
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +0000396 a spell directory in 'runtimepath', or ":set spelllang=xx.enc.spl" if you
Bram Moolenaard042c562005-06-30 22:04:15 +0000397 wrote it somewhere else.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000398
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000399When the Myspell files are updated you can merge the differences:
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00004001. Obtain the new Myspell files as xx_YY.new.aff and xx_UU.new.dic.
4012. Use Vimdiff to see what changed: >
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000402 vimdiff xx_YY.orig.dic xx_YY.new.dic
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00004033. Take over the changes you like in xx_YY.dic.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000404 You may also need to change xx_YY.aff.
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00004054. 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 +0000406
Bram Moolenaar3b506942005-06-23 22:36:45 +0000407
408SPELL FILE DUMP
409
410If for some reason you want to check what words are supported by the currently
411used spelling files, use this command:
412
413 *:spelldump* *:spelld*
414:spelld[ump] Open a new window and fill it with all currently valid
415 words.
Bram Moolenaard042c562005-06-30 22:04:15 +0000416 Note: For some languages the result may be enormous,
417 causing Vim to run out of memory.
Bram Moolenaar3b506942005-06-23 22:36:45 +0000418
419The format of the word list is used |spell-wordlist-format|. You should be
420able to read it with ":mkspell" to generate one .spl file that includes all
421the words.
422
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000423When all entries to 'spelllang' use the same regions or no regions at all then
424the region information is included in the dumped words. Otherwise only words
425for the current region are included and no "/regions" line is generated.
Bram Moolenaar3b506942005-06-23 22:36:45 +0000426
Bram Moolenaard042c562005-06-30 22:04:15 +0000427Comment lines with the name of the .spl file are used as a header above the
428words that were generated from that .spl file.
Bram Moolenaar3b506942005-06-23 22:36:45 +0000429
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000430==============================================================================
Bram Moolenaard042c562005-06-30 22:04:15 +00004314. Spell file format *spell-file-format*
Bram Moolenaar217ad922005-03-20 22:37:15 +0000432
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000433This is the format of the files that are used by the person who creates and
434maintains a word list.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000435
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000436Note that we avoid the word "dictionary" here. That is because the goal of
437spell checking differs from writing a dictionary (as in the book). For
Bram Moolenaard042c562005-06-30 22:04:15 +0000438spelling we need a list of words that are OK, thus should not to be
439highlighted. Person and company names will not appear in a dictionary, but do
440appear in a word list. And some old words are rarely used while they are
441common misspellings. These do appear in a dictionary but not in a word list.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000442
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +0000443There are two formats: A straight list of words and a list using affix
Bram Moolenaard042c562005-06-30 22:04:15 +0000444compression. The files with affix compression are used by Myspell (Mozilla
445and OpenOffice.org). This requires two files, one with .aff and one with .dic
446extension.
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000447
448
Bram Moolenaard042c562005-06-30 22:04:15 +0000449FORMAT OF STRAIGHT WORD LIST *spell-wordlist-format*
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000450
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000451The words must appear one per line. That is all that is required.
Bram Moolenaard042c562005-06-30 22:04:15 +0000452
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000453Additionally the following items are recognized:
Bram Moolenaard042c562005-06-30 22:04:15 +0000454
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000455- Empty and blank lines are ignored.
Bram Moolenaard042c562005-06-30 22:04:15 +0000456
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000457- Lines starting with a # are ignored (comment lines).
Bram Moolenaard042c562005-06-30 22:04:15 +0000458
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000459- A line starting with "/encoding=", before any word, specifies the encoding
460 of the file. After the second '=' comes an encoding name. This tells Vim
Bram Moolenaard042c562005-06-30 22:04:15 +0000461 to setup conversion from the specified encoding to 'encoding'. Thus you can
462 use one word list for several target encodings.
463
Bram Moolenaar3638c682005-06-08 22:05:14 +0000464- A line starting with "/regions=" specifies the region names that are
465 supported. Each region name must be two ASCII letters. The first one is
466 region 1. Thus "/regions=usca" has region 1 "us" and region 2 "ca".
Bram Moolenaard042c562005-06-30 22:04:15 +0000467 In an addition word list the region names should be equal to the main word
468 list!
469
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000470- Other lines starting with '/' are reserved for future use. The ones that
471 are not recognized are ignored (but you do get a warning message).
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000472
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000473- A "/" may follow the word with the following items:
474 = Case must match exactly.
475 ? Rare word.
476 ! Bad (wrong) word.
477 digit A region in which the word is valid. If no regions are
478 specified the word is valid in all regions.
479
Bram Moolenaar3638c682005-06-08 22:05:14 +0000480Example:
481
482 # This is an example word list comment
483 /encoding=latin1 encoding of the file
484 /regions=uscagb regions "us", "ca" and "gb"
485 example word for all regions
Bram Moolenaar1f8a5f02005-07-01 22:41:52 +0000486 blah/12 word for regions "us" and "ca"
487 vim/! bad word
488 Campbell/?3 rare word in region 3 "gb"
489 's mornings/= keep-case word
Bram Moolenaar3638c682005-06-08 22:05:14 +0000490
Bram Moolenaar75c50c42005-06-04 22:06:24 +0000491
492FORMAT WITH AFFIX COMPRESSION
493
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000494There are two files: the basic word list and an affix file. The affixes are
495used to modify the basic words to get the full word list. This significantly
496reduces the number of words, especially for a language like Polish. This is
497called affix compression.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000498
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000499The format for the affix and word list files is mostly identical to what
500Myspell uses (the spell checker of Mozilla and OpenOffice.org). A description
501can be found here:
502 http://lingucomponent.openoffice.org/affix.readme ~
503Note that affixes are case sensitive, this isn't obvious from the description.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000504
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000505Vim supports a few extras. Hopefully Myspell will support these too some day.
506See |spell-affix-vim|.
Bram Moolenaar217ad922005-03-20 22:37:15 +0000507
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000508The basic word list and the affix file are combined and turned into a binary
509spell file. All the preprocessing has been done, thus this file loads fast.
510The binary spell file format is described in the source code (src/spell.c).
511But only developers need to know about it.
512
513The preprocessing also allows us to take the Myspell language files and modify
514them before the Vim word list is made. The tools for this can be found in the
515"src/spell" directory.
516
517
Bram Moolenaar3638c682005-06-08 22:05:14 +0000518WORD LIST FORMAT *spell-dic-format*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000519
520A very short example, with line numbers:
521
522 1 1234
523 2 aan
524 3 Als
525 4 Etten-Leur
526 5 et al.
527 6 's-Gravenhage
528 7 's-Gravenhaags
529 8 bedel/P
530 9 kado/1
531 10 cadeau/2
532
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000533The first line contains the number of words. Vim ignores it, but you do get
534an error message if it's not there. *E760*
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000535
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000536What follows is one word per line. There should be no white space before or
537after the word.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000538
539When the word only has lower-case letters it will also match with the word
540starting with an upper-case letter.
541
542When the word includes an upper-case letter, this means the upper-case letter
543is required at this position. The same word with a lower-case letter at this
544position will not match. When some of the other letters are upper-case it will
545not match either.
546
Bram Moolenaard042c562005-06-30 22:04:15 +0000547The word with all upper-case characters will always be OK.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000548
549 word list matches does not match ~
550 als als Als ALS ALs AlS aLs aLS
551 Als Als ALS als ALs AlS aLs aLS
552 ALS ALS als Als ALs AlS aLs aLS
553 AlS AlS ALS als Als ALs aLs aLS
554
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000555The KEP affix ID can be used to specifically match a word with identical case
Bram Moolenaare7566042005-06-17 22:00:15 +0000556only, see below |spell-affix-KEP|.
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000557
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000558Note in line 5 to 7 that non-word characters are used. You can include
559any character in a word. When checking the text a word still only matches
560when it appears with a non-word character before and after it. For Myspell a
561word starting with a non-word character probably won't work.
562
563After the word there is an optional slash and flags. Most of these flags are
Bram Moolenaard042c562005-06-30 22:04:15 +0000564letters that indicate the affixes that can be used with this word. These are
565specified with SFX and PFX lines in the .aff file. See the Myspell
566documentation.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000567
568 *spell-affix-vim*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000569A flag that Vim adds and is not in Myspell is the flag defined with KEP in the
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000570affix file. This has the meaning that case matters. This can be used if the
571word does not have the first letter in upper case at the start of a sentence.
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000572Example (assuming that = was used for KEP):
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000573
574 word list matches does not match ~
575 's morgens/= 's morgens 'S morgens 's Morgens
576 's Morgens 's Morgens 'S morgens 's morgens
577
578 *spell-affix-mbyte*
579The basic word list is normally in an 8-bit encoding, which is mentioned in
580the affix file. The affix file must always be in the same encoding as the
581word list. This is compatible with Myspell. For Vim the encoding may also be
582something else, any encoding that "iconv" supports. The "SET" line must
583specify the name of the encoding. When using a multi-byte encoding it's
Bram Moolenaard042c562005-06-30 22:04:15 +0000584possible to use more different affixes (but Myspell doesn't support that, thus
585you may not want to use it anyway).
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000586
Bram Moolenaare13305e2005-06-19 22:54:15 +0000587
588CHARACTER TABLES
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000589 *spell-affix-chars*
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000590When using an 8-bit encoding the affix file should define what characters are
591word characters (as specified with ENC). This is because the system where
592":mkspell" is used may not support a locale with this encoding and isalpha()
593won't work. For example when using "cp1250" on Unix.
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000594
Bram Moolenaare7566042005-06-17 22:00:15 +0000595 *E761* *E762* *spell-affix-FOL*
596 *spell-affix-LOW* *spell-affix-UPP*
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000597Three lines in the affix file are needed. Simplistic example:
598
Bram Moolenaare13305e2005-06-19 22:54:15 +0000599 FOL áëñ ~
600 LOW áëñ ~
601 UPP ÁËÑ ~
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000602
603All three lines must have exactly the same number of characters.
604
605The "FOL" line specifies the case-folded characters. These are used to
606compare words while ignoring case. For most encodings this is identical to
607the lower case line.
608
609The "LOW" line specifies the characters in lower-case. Mostly it's equal to
610the "FOL" line.
611
612The "UPP" line specifies the characters with upper-case. That is, a character
613is upper-case where it's different from the character at the same position in
614"FOL".
615
616ASCII characters should be omitted, Vim always handles these in the same way.
617When the encoding is UTF-8 no word characters need to be specified.
618
619 *E763*
Bram Moolenaar3b506942005-06-23 22:36:45 +0000620Vim allows you to use spell checking for several languages in the same file.
621You can list them in the 'spelllang' option. As a consequence all spell files
622for the same encoding must use the same word characters, otherwise they can't
623be combined without errors. If you get a warning that the word tables differ
624you may need to generate the .spl file again with |:mkspell|. Check the FOL,
625LOW and UPP lines in the used .aff file.
626
627The XX.ascii.spl spell file generated with the "-ascii" argument will not
628contain the table with characters, so that it can be combine with spell files
629for any encoding. The .add.spl files also do not contain the table.
Bram Moolenaar0cb032e2005-04-23 20:52:00 +0000630
Bram Moolenaare7566042005-06-17 22:00:15 +0000631
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000632MID-WORD CHARACTERS
633 *spell-midword*
634Some characters are only to be considered word characters if they are used in
635between two ordinary word characters. An example is the single quote: It is
636often used to put text in quotes, thus it can't be recognized as a word
637character, but when it appears in between word characters it must be part of
638the word. This is needed to detect a spelling error such as they'are. That
639should be they're, but since "they" and "are" are words themselves that would
640go unnoticed.
641
642These characters are defined with MIDWORD in the .aff file:
643
644 MIDWORD '- ~
645
646
Bram Moolenaare13305e2005-06-19 22:54:15 +0000647AFFIXES
648 *spell-affix-PFX* *spell-affix-SFX*
649The usual PFX (prefix) and SFX (suffix) lines are supported (see the Myspell
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000650documentation or the Aspell manual:
651http://aspell.net/man-html/Affix-Compression.html).
Bram Moolenaare13305e2005-06-19 22:54:15 +0000652
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000653Note that Myspell ignores any extra text after the relevant info. Vim
654requires this text to start with a "#" so that mistakes don't go unnoticed.
655Example:
656
657 SFX F 0 in [^i]n # Spion > Spionin ~
658 SFX F 0 nen in # Bauerin > Bauerinnen ~
659
660An extra item for Vim is the "rare" flag. It must come after the other
661fields, before a comment. When used then all words that use the affix will be
662marked as rare words. Example:
663
664 PFX F 0 nene . rare ~
665 SFX F 0 oin n rare # hardly ever used ~
666
667However, if the word also appears as a good word in another way it won't be
668marked as rare.
Bram Moolenaare13305e2005-06-19 22:54:15 +0000669
670 *spell-affix-PFXPOSTPONE*
671When an affix file has very many prefixes that apply to many words it's not
672possible to build the whole word list in memory. This applies to Hebrew (a
673list with all words is over a Gbyte). In that case applying prefixes must be
674postponed. This makes spell checking slower. It is indicated by this keyword
675in the .aff file:
676
677 PFXPOSTPONE ~
678
679Only prefixes without a chop string can be postponed, prefixes with a chop
680string will still be included in the word list.
681
682
683KEEP-CASE WORDS
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000684 *spell-affix-KEP*
685In the affix file a KEP line can be used to define the affix name used for
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000686keep-case words. Example:
687
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000688 KEP = ~
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000689
690See above for an example |spell-affix-vim|.
691
Bram Moolenaare13305e2005-06-19 22:54:15 +0000692
693RARE WORDS
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000694 *spell-affix-RAR*
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000695In the affix file a RAR line can be used to define the affix name used for
696rare words. Example:
697
698 RAR ? ~
699
700Rare words are highlighted differently from bad words. This is to be used for
701words that are correct for the language, but are hardly ever used and could be
Bram Moolenaar30abd282005-06-22 22:35:10 +0000702a typing mistake anyway. When the same word is found as good it won't be
703highlighted as rare.
704
705
706BAD WORDS
707 *spell-affix-BAD*
708In the affix file a BAD line can be used to define the affix name used for
709bad words. Example:
710
711 BAD ! ~
712
713This can be used to exclude words that would otherwise be good. For example
Bram Moolenaar9a50b1b2005-06-27 22:48:21 +0000714"the the" in the .dic file:
715
716 the the/! ~
717
718Once a word has been marked as bad it won't be undone by encountering the same
719word as good.
Bram Moolenaar45eeb132005-06-06 21:59:07 +0000720
721
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000722REPLACEMENTS *spell-affix-REP*
723
724In the affix file REP items can be used to define common mistakes. This is
725used to make spelling suggestions. The items define the "from" text and the
726"to" replacement. Example:
727
728 REP 4 ~
729 REP f ph ~
730 REP ph f ~
731 REP k ch ~
732 REP ch k ~
733
734The first line specifies the number of REP lines following. Vim ignores it.
Bram Moolenaard042c562005-06-30 22:04:15 +0000735Don't include simple one-character replacements or swaps. Vim will try these
736anyway. You can include whole words if you want to, but you might want to use
737the "file:" item in 'spellsuggest' instead.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000738
739
740SIMILAR CHARACTERS *spell-affix-MAP*
741
Bram Moolenaard042c562005-06-30 22:04:15 +0000742In the affix file MAP items can be used to define letters that are very much
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000743alike. This is mostly used for a letter with different accents. This is used
744to prefer suggestions with these letters substituted. Example:
745
746 MAP 2 ~
747 MAP eéëêè ~
748 MAP uüùúû ~
749
750The first line specifies the number of MAP lines following. Vim ignores it.
751
Bram Moolenaard042c562005-06-30 22:04:15 +0000752Each letter must appear in only one of the MAP items. It's a bit more
753efficient if the first letter is ASCII or at least one without accents.
Bram Moolenaare7566042005-06-17 22:00:15 +0000754
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000755
Bram Moolenaard042c562005-06-30 22:04:15 +0000756SOUND-A-LIKE *spell-affix-SAL*
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000757
758In the affix file SAL items can be used to define the sounds-a-like mechanism
759to be used. The main items define the "from" text and the "to" replacement.
Bram Moolenaard042c562005-06-30 22:04:15 +0000760Simplistic example:
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000761
762 SAL CIA X ~
763 SAL CH X ~
764 SAL C K ~
765 SAL K K ~
766
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +0000767There are a few rules and this can become quite complicated. An explanation
Bram Moolenaard042c562005-06-30 22:04:15 +0000768how it works can be found in the Aspell manual:
Bram Moolenaar42eeac32005-06-29 22:40:58 +0000769http://aspell.net/man-html/Phonetic-Code.html.
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +0000770
771There are a few special items:
772
773 SAL followup true ~
774 SAL collapse_result true ~
775 SAL remove_accents true ~
776
777"1" has the same meaning as "true". Any other value means "false".
778
Bram Moolenaar42eeac32005-06-29 22:40:58 +0000779
780SIMPLE SOUNDFOLDING *spell-affix-SOFOFROM* *spell-affix-SOFOTO*
781
782The SAL mechanism is complex and slow. A simpler mechanism is mapping all
783characters to another character, mapping similar sounding characters to the
784same character. At the same time this does case folding. You can not have
Bram Moolenaard042c562005-06-30 22:04:15 +0000785both SAL items and simple soundfolding.
Bram Moolenaar42eeac32005-06-29 22:40:58 +0000786
Bram Moolenaar7d1f5db2005-07-03 21:39:27 +0000787There are two items required: one to specify the characters that are mapped
Bram Moolenaar42eeac32005-06-29 22:40:58 +0000788and one that specifies the characters they are mapped to. They must have
789exactly the same number of characters. Example:
790
791 SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~
792 SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkes ~
793
794In the example all vowels are mapped to the same character 'e'. Another
Bram Moolenaard042c562005-06-30 22:04:15 +0000795method would be to leave out all vowels. Some characters that sound nearly
796the same and are often mixed up, such as 'm' and 'n', are mapped to the same
797character. Don't do this too much, all words will start looking alike.
Bram Moolenaar42eeac32005-06-29 22:40:58 +0000798
799Characters that do not appear in SOFOFROM will be left out, except that all
800white space is replaced by one space. Sequences of the same character in
801SOFOFROM are replaced by one.
802
803You can use the |soundfold()| function to try out the results. Or set the
804'verbose' option to see the score in the output of the |z?| command.
805
806
Bram Moolenaar217ad922005-03-20 22:37:15 +0000807 vim:tw=78:sw=4:ts=8:ft=help:norl: