xref: /vim-8.2.3635/runtime/doc/spell.txt (revision 362b44bd)
1*spell.txt*	For Vim version 8.2.  Last change: 2019 Aug 16
2
3
4		  VIM REFERENCE MANUAL	  by Bram Moolenaar
5
6
7Spell checking						*spell*
8
91. Quick start			|spell-quickstart|
102. Remarks on spell checking	|spell-remarks|
113. Generating a spell file	|spell-mkspell|
124. Spell file format		|spell-file-format|
13
14{not available when the |+syntax| feature has been disabled at compile time}
15
16Note: There also is a vimspell plugin.  If you have it you can do ":help
17vimspell" to find about it.  But you will probably want to get rid of the
18plugin and use the 'spell' option instead, it works better.
19
20==============================================================================
211. Quick start					*spell-quickstart* *E756*
22
23This command switches on spell checking: >
24
25	:setlocal spell spelllang=en_us
26
27This switches on the 'spell' option and specifies to check for US English.
28
29The words that are not recognized are highlighted with one of these:
30	SpellBad	word not recognized			|hl-SpellBad|
31	SpellCap	word not capitalised			|hl-SpellCap|
32	SpellRare	rare word				|hl-SpellRare|
33	SpellLocal	wrong spelling for selected region	|hl-SpellLocal|
34
35Vim only checks words for spelling, there is no grammar check.
36
37If the 'mousemodel' option is set to "popup" and the cursor is on a badly
38spelled word or it is "popup_setpos" and the mouse pointer is on a badly
39spelled word, then the popup menu will contain a submenu to replace the bad
40word.  Note: this slows down the appearance of the popup menu.  Note for GTK:
41don't release the right mouse button until the menu appears, otherwise it
42won't work.
43
44To search for the next misspelled word:
45
46							*]s*
47]s			Move to next misspelled word after the cursor.
48			A count before the command can be used to repeat.
49			'wrapscan' applies.
50
51							*[s*
52[s			Like "]s" but search backwards, find the misspelled
53			word before the cursor.  Doesn't recognize words
54			split over two lines, thus may stop at words that are
55			not highlighted as bad.  Does not stop at word with
56			missing capital at the start of a line.
57
58							*]S*
59]S			Like "]s" but only stop at bad words, not at rare
60			words or words for another region.
61
62							*[S*
63[S			Like "]S" but search backwards.
64
65
66To add words to your own word list:
67
68							*zg*
69zg			Add word under the cursor as a good word to the first
70			name in 'spellfile'.  A count may precede the command
71			to indicate the entry in 'spellfile' to be used.  A
72			count of two uses the second entry.
73
74			In Visual mode the selected characters are added as a
75			word (including white space!).
76			When the cursor is on text that is marked as badly
77			spelled then the marked text is used.
78			Otherwise the word under the cursor, separated by
79			non-word characters, is used.
80
81			If the word is explicitly marked as bad word in
82			another spell file the result is unpredictable.
83
84							*zG*
85zG			Like "zg" but add the word to the internal word list
86			|internal-wordlist|.
87
88							*zw*
89zw			Like "zg" but mark the word as a wrong (bad) word.
90			If the word already appears in 'spellfile' it is
91			turned into a comment line.  See |spellfile-cleanup|
92			for getting rid of those.
93
94							*zW*
95zW			Like "zw" but add the word to the internal word list
96			|internal-wordlist|.
97
98zuw							*zug* *zuw*
99zug			Undo |zw| and |zg|, remove the word from the entry in
100			'spellfile'.  Count used as with |zg|.
101
102zuW							*zuG* *zuW*
103zuG			Undo |zW| and |zG|, remove the word from the internal
104			word list.  Count used as with |zg|.
105
106							*:spe* *:spellgood*
107:[count]spe[llgood] {word}
108			Add {word} as a good word to 'spellfile', like with
109			|zg|.  Without count the first name is used, with a
110			count of two the second entry, etc.
111
112:spe[llgood]! {word}	Add {word} as a good word to the internal word list,
113			like with |zG|.
114
115							*:spellw* *:spellwrong*
116:[count]spellw[rong] {word}
117			Add {word} as a wrong (bad) word to 'spellfile', as
118			with |zw|.  Without count the first name is used, with
119			a count of two the second entry, etc.
120
121:spellw[rong]! {word}	Add {word} as a wrong (bad) word to the internal word
122			list, like with |zW|.
123
124							*:spellra* *:spellrare*
125:[count]spellr[are] {word}
126			Add {word} as a rare word to 'spellfile', similar to
127			|zw|.  Without count the first name is used, with
128			a count of two the second entry, etc.
129
130			There are no normal mode commands to mark words as
131			rare as this is a fairly uncommon command and all
132			intuitive commands for this are already taken. If you
133			want you can add mappings with e.g.: >
134		nnoremap z?  :exe ':spellrare  ' . expand('<cWORD>')<CR>
135		nnoremap z/  :exe ':spellrare! ' . expand('<cWORD>')<CR>
136<			|:spellundo|, |zuw|, or |zuW| can be used to undo this.
137
138:spellr[rare]! {word}	Add {word} as a rare word to the internal word
139			list, similar to |zW|.
140
141:[count]spellu[ndo] {word}				*:spellu* *:spellundo*
142			Like |zuw|.  [count] used as with |:spellgood|.
143
144:spellu[ndo]! {word}	Like |zuW|.  [count] used as with |:spellgood|.
145
146
147After adding a word to 'spellfile' with the above commands its associated
148".spl" file will automatically be updated and reloaded.  If you change
149'spellfile' manually you need to use the |:mkspell| command.  This sequence of
150commands mostly works well: >
151	:edit <file in 'spellfile'>
152<	(make changes to the spell file) >
153	:mkspell! %
154
155More details about the 'spellfile' format below |spell-wordlist-format|.
156
157							*internal-wordlist*
158The internal word list is used for all buffers where 'spell' is set.  It is
159not stored, it is lost when you exit Vim.  It is also cleared when 'encoding'
160is set.
161
162
163Finding suggestions for bad words:
164							*z=*
165z=			For the word under/after the cursor suggest correctly
166			spelled words.  This also works to find alternatives
167			for a word that is not highlighted as a bad word,
168			e.g., when the word after it is bad.
169			In Visual mode the highlighted text is taken as the
170			word to be replaced.
171			The results are sorted on similarity to the word being
172			replaced.
173			This may take a long time.  Hit CTRL-C when you get
174			bored.
175
176			If the command is used without a count the
177			alternatives are listed and you can enter the number
178			of your choice or press <Enter> if you don't want to
179			replace.  You can also use the mouse to click on your
180			choice (only works if the mouse can be used in Normal
181			mode and when there are no line wraps).  Click on the
182			first line (the header) to cancel.
183
184			The suggestions listed normally replace a highlighted
185			bad word.  Sometimes they include other text, in that
186			case the replaced text is also listed after a "<".
187
188			If a count is used that suggestion is used, without
189			prompting.  For example, "1z=" always takes the first
190			suggestion.
191
192			If 'verbose' is non-zero a score will be displayed
193			with the suggestions to indicate the likeliness to the
194			badly spelled word (the higher the score the more
195			different).
196			When a word was replaced the redo command "." will
197			repeat the word replacement.  This works like "ciw",
198			the good word and <Esc>.  This does NOT work for Thai
199			and other languages without spaces between words.
200
201					*:spellr* *:spellrepall* *E752* *E753*
202:spellr[epall]		Repeat the replacement done by |z=| for all matches
203			with the replaced word in the current window.
204
205In Insert mode, when the cursor is after a badly spelled word, you can use
206CTRL-X s to find suggestions.  This works like Insert mode completion.  Use
207CTRL-N to use the next suggestion, CTRL-P to go back. |i_CTRL-X_s|
208
209The 'spellsuggest' option influences how the list of suggestions is generated
210and sorted.  See |'spellsuggest'|.
211
212The 'spellcapcheck' option is used to check the first word of a sentence
213starts with a capital.  This doesn't work for the first word in the file.
214When there is a line break right after a sentence the highlighting of the next
215line may be postponed.  Use |CTRL-L| when needed.  Also see |set-spc-auto| for
216how it can be set automatically when 'spelllang' is set.
217
218The 'spelloptions' option has a few more flags that influence the way spell
219checking works.
220
221Vim counts the number of times a good word is encountered.  This is used to
222sort the suggestions: words that have been seen before get a small bonus,
223words that have been seen often get a bigger bonus.  The COMMON item in the
224affix file can be used to define common words, so that this mechanism also
225works in a new or short file |spell-COMMON|.
226
227==============================================================================
2282. Remarks on spell checking				*spell-remarks*
229
230PERFORMANCE
231
232Vim does on-the-fly spell checking.  To make this work fast the word list is
233loaded in memory.  Thus this uses a lot of memory (1 Mbyte or more).  There
234might also be a noticeable delay when the word list is loaded, which happens
235when 'spell' is set and when 'spelllang' is set while 'spell' was already set.
236To minimize the delay each word list is only loaded once, it is not deleted
237when 'spelllang' is made empty or 'spell' is reset.  When 'encoding' is set
238all the word lists are reloaded, thus you may notice a delay then too.
239
240
241REGIONS
242
243A word may be spelled differently in various regions.  For example, English
244comes in (at least) these variants:
245
246	en		all regions
247	en_au		Australia
248	en_ca		Canada
249	en_gb		Great Britain
250	en_nz		New Zealand
251	en_us		USA
252
253Words that are not used in one region but are used in another region are
254highlighted with SpellLocal |hl-SpellLocal|.
255
256Always use lowercase letters for the language and region names.
257
258When adding a word with |zg| or another command it's always added for all
259regions.  You can change that by manually editing the 'spellfile'.  See
260|spell-wordlist-format|.  Note that the regions as specified in the files in
261'spellfile' are only used when all entries in 'spelllang' specify the same
262region (not counting files specified by their .spl name).
263
264							*spell-german*
265Specific exception: For German these special regions are used:
266	de		all German words accepted
267	de_de		old and new spelling
268	de_19		old spelling
269	de_20		new spelling
270	de_at		Austria
271	de_ch		Switzerland
272
273							*spell-russian*
274Specific exception: For Russian these special regions are used:
275	ru		all Russian words accepted
276	ru_ru		"IE" letter spelling
277	ru_yo		"YO" letter spelling
278
279							*spell-yiddish*
280Yiddish requires using "utf-8" encoding, because of the special characters
281used.  If you are using latin1 Vim will use transliterated (romanized) Yiddish
282instead.  If you want to use transliterated Yiddish with utf-8 use "yi-tr".
283In a table:
284	'encoding'	'spelllang'
285	utf-8		yi		Yiddish
286	latin1		yi		transliterated Yiddish
287	utf-8		yi-tr		transliterated Yiddish
288
289							*spell-cjk*
290Chinese, Japanese and other East Asian characters are normally marked as
291errors, because spell checking of these characters is not supported. If
292'spelllang' includes "cjk", these characters are not marked as errors.  This
293is useful when editing text with spell checking while some Asian words are
294present.
295
296
297SPELL FILES						*spell-load*
298
299Vim searches for spell files in the "spell" subdirectory of the directories in
300'runtimepath'.  The name is: LL.EEE.spl, where:
301	LL	the language name
302	EEE	the value of 'encoding'
303
304The value for "LL" comes from 'spelllang', but excludes the region name.
305Examples:
306	'spelllang'	LL ~
307	en_us		en
308	en-rare		en-rare
309	medical_ca	medical
310
311Only the first file is loaded, the one that is first in 'runtimepath'.  If
312this succeeds then additionally files with the name LL.EEE.add.spl are loaded.
313All the ones that are found are used.
314
315If no spell file is found the |SpellFileMissing| autocommand event is
316triggered.  This may trigger the |spellfile.vim| plugin to offer you
317downloading the spell file.
318
319Additionally, the files related to the names in 'spellfile' are loaded.  These
320are the files that |zg| and |zw| add good and wrong words to.
321
322Exceptions:
323- Vim uses "latin1" when 'encoding' is "iso-8859-15".  The euro sign doesn't
324  matter for spelling.
325- When no spell file for 'encoding' is found "ascii" is tried.  This only
326  works for languages where nearly all words are ASCII, such as English.  It
327  helps when 'encoding' is not "latin1", such as iso-8859-2, and English text
328  is being edited.  For the ".add" files the same name as the found main
329  spell file is used.
330
331For example, with these values:
332	'runtimepath' is "~/.vim,/usr/share/vim82,~/.vim/after"
333	'encoding'    is "iso-8859-2"
334	'spelllang'   is "pl"
335
336Vim will look for:
3371. ~/.vim/spell/pl.iso-8859-2.spl
3382. /usr/share/vim82/spell/pl.iso-8859-2.spl
3393. ~/.vim/spell/pl.iso-8859-2.add.spl
3404. /usr/share/vim82/spell/pl.iso-8859-2.add.spl
3415. ~/.vim/after/spell/pl.iso-8859-2.add.spl
342
343This assumes 1. is not found and 2. is found.
344
345If 'encoding' is "latin1" Vim will look for:
3461. ~/.vim/spell/pl.latin1.spl
3472. /usr/share/vim82/spell/pl.latin1.spl
3483. ~/.vim/after/spell/pl.latin1.spl
3494. ~/.vim/spell/pl.ascii.spl
3505. /usr/share/vim82/spell/pl.ascii.spl
3516. ~/.vim/after/spell/pl.ascii.spl
352
353This assumes none of them are found (Polish doesn't make sense when leaving
354out the non-ASCII characters).
355
356Spelling for EBCDIC is currently not supported.
357
358A spell file might not be available in the current 'encoding'.  See
359|spell-mkspell| about how to create a spell file.  Converting a spell file
360with "iconv" will NOT work!
361
362Note: on VMS ".{enc}.spl" is changed to "_{enc}.spl" to avoid trouble with
363filenames.
364
365						    *spell-sug-file* *E781*
366If there is a file with exactly the same name as the ".spl" file but ending in
367".sug", that file will be used for giving better suggestions.  It isn't loaded
368before suggestions are made to reduce memory use.
369
370				    *E758* *E759* *E778* *E779* *E780* *E782*
371When loading a spell file Vim checks that it is properly formatted.  If you
372get an error the file may be truncated, modified or intended for another Vim
373version.
374
375
376SPELLFILE CLEANUP					*spellfile-cleanup*
377
378The |zw| command turns existing entries in 'spellfile' into comment lines.
379This avoids having to write a new file every time, but results in the file
380only getting longer, never shorter.  To clean up the comment lines in all
381".add" spell files do this: >
382	:runtime spell/cleanadd.vim
383
384This deletes all comment lines, except the ones that start with "##".  Use
385"##" lines to add comments that you want to keep.
386
387You can invoke this script as often as you like.  A variable is provided to
388skip updating files that have been changed recently.  Set it to the number of
389seconds that has passed since a file was changed before it will be cleaned.
390For example, to clean only files that were not changed in the last hour: >
391      let g:spell_clean_limit = 60 * 60
392The default is one second.
393
394
395WORDS
396
397Vim uses a fixed method to recognize a word.  This is independent of
398'iskeyword', so that it also works in help files and for languages that
399include characters like '-' in 'iskeyword'.  The word characters do depend on
400'encoding'.
401
402The table with word characters is stored in the main .spl file.  Therefore it
403matters what the current locale is when generating it!  A .add.spl file does
404not contain a word table though.
405
406For a word that starts with a digit the digit is ignored, unless the word as a
407whole is recognized.  Thus if "3D" is a word and "D" is not then "3D" is
408recognized as a word, but if "3D" is not a word then only the "D" is marked as
409bad.  Hex numbers in the form 0x12ab and 0X12AB are recognized.
410
411
412WORD COMBINATIONS
413
414It is possible to spell-check words that include a space.  This is used to
415recognize words that are invalid when used by themselves, e.g. for "et al.".
416It can also be used to recognize "the the" and highlight it.
417
418The number of spaces is irrelevant.  In most cases a line break may also
419appear.  However, this makes it difficult to find out where to start checking
420for spelling mistakes.  When you make a change to one line and only that line
421is redrawn Vim won't look in the previous line, thus when "et" is at the end
422of the previous line "al." will be flagged as an error.  And when you type
423"the<CR>the" the highlighting doesn't appear until the first line is redrawn.
424Use |CTRL-L| to redraw right away.  "[s" will also stop at a word combination
425with a line break.
426
427When encountering a line break Vim skips characters such as '*', '>' and '"',
428so that comments in C, shell and Vim code can be spell checked.
429
430
431SYNTAX HIGHLIGHTING					*spell-syntax*
432
433Files that use syntax highlighting can specify where spell checking should be
434done:
435
4361.  everywhere			   default
4372.  in specific items		   use "contains=@Spell"
4383.  everywhere but specific items  use "contains=@NoSpell"
439
440For the second method adding the @NoSpell cluster will disable spell checking
441again.  This can be used, for example, to add @Spell to the comments of a
442program, and add @NoSpell for items that shouldn't be checked.
443Also see |:syn-spell| for text that is not in a syntax item.
444
445
446VIM SCRIPTS
447
448If you want to write a Vim script that does something with spelling, you may
449find these functions useful:
450
451    spellbadword()	find badly spelled word at the cursor
452    spellsuggest()	get list of spelling suggestions
453    soundfold()		get the sound-a-like version of a word
454
455
456SETTING 'spellcapcheck' AUTOMATICALLY			*set-spc-auto*
457
458After the 'spelllang' option has been set successfully, Vim will source the
459files "spell/LANG.vim" in 'runtimepath'.  "LANG" is the value of 'spelllang'
460up to the first comma, dot or underscore.  This can be used to set options
461specifically for the language, especially 'spellcapcheck'.
462
463The distribution includes a few of these files.  Use this command to see what
464they do: >
465	:next $VIMRUNTIME/spell/*.vim
466
467Note that the default scripts don't set 'spellcapcheck' if it was changed from
468the default value.  This assumes the user prefers another value then.
469
470
471DOUBLE SCORING						*spell-double-scoring*
472
473The 'spellsuggest' option can be used to select "double" scoring.  This
474mechanism is based on the principle that there are two kinds of spelling
475mistakes:
476
4771. You know how to spell the word, but mistype something.  This results in a
478   small editing distance (character swapped/omitted/inserted) and possibly a
479   word that sounds completely different.
480
4812. You don't know how to spell the word and type something that sounds right.
482   The edit distance can be big but the word is similar after sound-folding.
483
484Since scores for these two mistakes will be very different we use a list
485for each and mix them.
486
487The sound-folding is slow and people that know the language won't make the
488second kind of mistakes.  Therefore 'spellsuggest' can be set to select the
489preferred method for scoring the suggestions.
490
491==============================================================================
4923. Generating a spell file				*spell-mkspell*
493
494Vim uses a binary file format for spelling.  This greatly speeds up loading
495the word list and keeps it small.
496						    *.aff* *.dic* *Myspell*
497You can create a Vim spell file from the .aff and .dic files that Myspell
498uses.  Myspell is used by OpenOffice.org and Mozilla. The OpenOffice .oxt
499files are zip files which contain the .aff and .dic files. You should be able
500to find them here:
501	http://extensions.services.openoffice.org/dictionary
502The older, OpenOffice 2 files may be used if this doesn't work:
503	http://wiki.services.openoffice.org/wiki/Dictionaries
504You can also use a plain word list.  The results are the same, the choice
505depends on what word lists you can find.
506
507If you install Aap (from www.a-a-p.org) you can use the recipes in the
508runtime/spell/??/ directories.  Aap will take care of downloading the files,
509apply patches needed for Vim and build the .spl file.
510
511Make sure your current locale is set properly, otherwise Vim doesn't know what
512characters are upper/lower case letters.  If the locale isn't available (e.g.,
513when using an MS-Windows codepage on Unix) add tables to the .aff file
514|spell-affix-chars|.  If the .aff file doesn't define a table then the word
515table of the currently active spelling is used.  If spelling is not active
516then Vim will try to guess.
517
518							*:mksp* *:mkspell*
519:mksp[ell][!] [-ascii] {outname} {inname} ...
520			Generate a Vim spell file from word lists.  Example: >
521		:mkspell /tmp/nl nl_NL.words
522<								*E751*
523			When {outname} ends in ".spl" it is used as the output
524			file name.  Otherwise it should be a language name,
525			such as "en", without the region name.  The file
526			written will be "{outname}.{encoding}.spl", where
527			{encoding} is the value of the 'encoding' option.
528
529			When the output file already exists [!] must be used
530			to overwrite it.
531
532			When the [-ascii] argument is present, words with
533			non-ascii characters are skipped.  The resulting file
534			ends in "ascii.spl".
535
536			The input can be the Myspell format files {inname}.aff
537			and {inname}.dic.  If {inname}.aff does not exist then
538			{inname} is used as the file name of a plain word
539			list.
540
541			Multiple {inname} arguments can be given to combine
542			regions into one Vim spell file.  Example: >
543		:mkspell ~/.vim/spell/en /tmp/en_US /tmp/en_CA /tmp/en_AU
544<			This combines the English word lists for US, CA and AU
545			into one en.spl file.
546			Up to eight regions can be combined. *E754* *E755*
547			The REP and SAL items of the first .aff file where
548			they appear are used. |spell-REP| |spell-SAL|
549								*E845*
550			This command uses a lot of memory, required to find
551			the optimal word tree (Polish, Italian and Hungarian
552			require several hundred Mbyte).  The final result will
553			be much smaller, because compression is used.  To
554			avoid running out of memory compression will be done
555			now and then.  This can be tuned with the 'mkspellmem'
556			option.
557
558			After the spell file was written and it was being used
559			in a buffer it will be reloaded automatically.
560
561:mksp[ell] [-ascii] {name}.{enc}.add
562			Like ":mkspell" above, using {name}.{enc}.add as the
563			input file and producing an output file in the same
564			directory that has ".spl" appended.
565
566:mksp[ell] [-ascii] {name}
567			Like ":mkspell" above, using {name} as the input file
568			and producing an output file in the same directory
569			that has ".{enc}.spl" appended.
570
571Vim will report the number of duplicate words.  This might be a mistake in the
572list of words.  But sometimes it is used to have different prefixes and
573suffixes for the same basic word to avoid them combining (e.g. Czech uses
574this).  If you want Vim to report all duplicate words set the 'verbose'
575option.
576
577Since you might want to change a Myspell word list for use with Vim the
578following procedure is recommended:
579
5801. Obtain the xx_YY.aff and xx_YY.dic files from Myspell.
5812. Make a copy of these files to xx_YY.orig.aff and xx_YY.orig.dic.
5823. Change the xx_YY.aff and xx_YY.dic files to remove bad words, add missing
583   words, define word characters with FOL/LOW/UPP, etc.  The distributed
584   "*.diff" files can be used.
5854. Start Vim with the right locale and use |:mkspell| to generate the Vim
586   spell file.
5875. Try out the spell file with ":set spell spelllang=xx" if you wrote it in
588   a spell directory in 'runtimepath', or ":set spelllang=xx.enc.spl" if you
589   wrote it somewhere else.
590
591When the Myspell files are updated you can merge the differences:
5921. Obtain the new Myspell files as xx_YY.new.aff and xx_UU.new.dic.
5932. Use Vimdiff to see what changed: >
594	vimdiff xx_YY.orig.dic xx_YY.new.dic
5953. Take over the changes you like in xx_YY.dic.
596   You may also need to change xx_YY.aff.
5974. Rename xx_YY.new.dic to xx_YY.orig.dic and xx_YY.new.aff to xx_YY.orig.aff.
598
599
600SPELL FILE VERSIONS					*E770* *E771* *E772*
601
602Spell checking is a relatively new feature in Vim, thus it's possible that the
603.spl file format will be changed to support more languages.  Vim will check
604the validity of the spell file and report anything wrong.
605
606	E771: Old spell file, needs to be updated ~
607This spell file is older than your Vim.  You need to update the .spl file.
608
609	E772: Spell file is for newer version of Vim ~
610This means the spell file was made for a later version of Vim.  You need to
611update Vim.
612
613	E770: Unsupported section in spell file ~
614This means the spell file was made for a later version of Vim and contains a
615section that is required for the spell file to work.  In this case it's
616probably a good idea to upgrade your Vim.
617
618
619SPELL FILE DUMP
620
621If for some reason you want to check what words are supported by the currently
622used spelling files, use this command:
623
624							*:spelldump* *:spelld*
625:spelld[ump]		Open a new window and fill it with all currently valid
626			words.  Compound words are not included.
627			Note: For some languages the result may be enormous,
628			causing Vim to run out of memory.
629
630:spelld[ump]!		Like ":spelldump" and include the word count.  This is
631			the number of times the word was found while
632			updating the screen.  Words that are in COMMON items
633			get a starting count of 10.
634
635The format of the word list is used |spell-wordlist-format|.  You should be
636able to read it with ":mkspell" to generate one .spl file that includes all
637the words.
638
639When all entries to 'spelllang' use the same regions or no regions at all then
640the region information is included in the dumped words.  Otherwise only words
641for the current region are included and no "/regions" line is generated.
642
643Comment lines with the name of the .spl file are used as a header above the
644words that were generated from that .spl file.
645
646
647SPELL FILE MISSING		*spell-SpellFileMissing* *spellfile.vim*
648
649If the spell file for the language you are using is not available, you will
650get an error message.  But if the "spellfile.vim" plugin is active it will
651offer you to download the spell file.  Just follow the instructions, it will
652ask you where to write the file (there must be a writable directory in
653'runtimepath' for this).
654
655The plugin has a default place where to look for spell files, on the Vim ftp
656server.  If you want to use another location or another protocol, set the
657g:spellfile_URL variable to the directory that holds the spell files.  The
658|netrw| plugin is used for getting the file, look there for the specific
659syntax of the URL.  Example: >
660	let g:spellfile_URL = 'http://ftp.vim.org/vim/runtime/spell'
661You may need to escape special characters.
662
663The plugin will only ask about downloading a language once.  If you want to
664try again anyway restart Vim, or set g:spellfile_URL to another value (e.g.,
665prepend a space).
666
667To avoid using the "spellfile.vim" plugin do this in your vimrc file: >
668
669	let loaded_spellfile_plugin = 1
670
671Instead of using the plugin you can define a |SpellFileMissing| autocommand to
672handle the missing file yourself.  You can use it like this: >
673
674	:au SpellFileMissing * call Download_spell_file(expand('<amatch>'))
675
676Thus the <amatch> item contains the name of the language.  Another important
677value is 'encoding', since every encoding has its own spell file.  With two
678exceptions:
679- For ISO-8859-15 (latin9) the name "latin1" is used (the encodings only
680  differ in characters not used in dictionary words).
681- The name "ascii" may also be used for some languages where the words use
682  only ASCII letters for most of the words.
683
684The default "spellfile.vim" plugin uses this autocommand, if you define your
685autocommand afterwards you may want to use ":au! SpellFileMissing" to overrule
686it.  If you define your autocommand before the plugin is loaded it will notice
687this and not do anything.
688							*E797*
689Note that the SpellFileMissing autocommand must not change or destroy the
690buffer the user was editing.
691
692==============================================================================
6934. Spell file format					*spell-file-format*
694
695This is the format of the files that are used by the person who creates and
696maintains a word list.
697
698Note that we avoid the word "dictionary" here.  That is because the goal of
699spell checking differs from writing a dictionary (as in the book).  For
700spelling we need a list of words that are OK, thus should not be highlighted.
701Person and company names will not appear in a dictionary, but do appear in a
702word list.  And some old words are rarely used while they are common
703misspellings.  These do appear in a dictionary but not in a word list.
704
705There are two formats: A straight list of words and a list using affix
706compression.  The files with affix compression are used by Myspell (Mozilla
707and OpenOffice.org).  This requires two files, one with .aff and one with .dic
708extension.
709
710
711FORMAT OF STRAIGHT WORD LIST				*spell-wordlist-format*
712
713The words must appear one per line.  That is all that is required.
714
715Additionally the following items are recognized:
716
717- Empty and blank lines are ignored.
718
719	# comment ~
720- Lines starting with a # are ignored (comment lines).
721
722	/encoding=utf-8 ~
723- A line starting with "/encoding=", before any word, specifies the encoding
724  of the file.  After the second '=' comes an encoding name.  This tells Vim
725  to setup conversion from the specified encoding to 'encoding'.  Thus you can
726  use one word list for several target encodings.
727
728	/regions=usca ~
729- A line starting with "/regions=" specifies the region names that are
730  supported.  Each region name must be two ASCII letters.  The first one is
731  region 1.  Thus "/regions=usca" has region 1 "us" and region 2 "ca".
732  In an addition word list the region names should be equal to the main word
733  list!
734
735- Other lines starting with '/' are reserved for future use.  The ones that
736  are not recognized are ignored.  You do get a warning message, so that you
737  know something won't work.
738
739- A "/" may follow the word with the following items:
740    =		Case must match exactly.
741    ?		Rare word.
742    !		Bad (wrong) word.
743    1 to 9	A region in which the word is valid.  If no regions are
744		specified the word is valid in all regions.
745
746Example:
747
748	# This is an example word list		comment
749	/encoding=latin1			encoding of the file
750	/regions=uscagb				regions "us", "ca" and "gb"
751	example					word for all regions
752	blah/12					word for regions "us" and "ca"
753	vim/!					bad word
754	Campbell/?3				rare word in region 3 "gb"
755	's mornings/=				keep-case word
756
757Note that when "/=" is used the same word with all upper-case letters is not
758accepted.  This is different from a word with mixed case that is automatically
759marked as keep-case, those words may appear in all upper-case letters.
760
761
762FORMAT WITH .AFF AND .DIC FILES				*aff-dic-format*
763
764There are two files: the basic word list and an affix file.  The affix file
765specifies settings for the language and can contain affixes.  The affixes are
766used to modify the basic words to get the full word list.  This significantly
767reduces the number of words, especially for a language like Polish.  This is
768called affix compression.
769
770The basic word list and the affix file are combined with the ":mkspell"
771command and results in a binary spell file.  All the preprocessing has been
772done, thus this file loads fast.  The binary spell file format is described in
773the source code (src/spell.c).  But only developers need to know about it.
774
775The preprocessing also allows us to take the Myspell language files and modify
776them before the Vim word list is made.  The tools for this can be found in the
777"src/spell" directory.
778
779The format for the affix and word list files is based on what Myspell uses
780(the spell checker of Mozilla and OpenOffice.org).  A description can be found
781here:
782	http://lingucomponent.openoffice.org/affix.readme ~
783Note that affixes are case sensitive, this isn't obvious from the description.
784
785Vim supports quite a few extras.  They are described below |spell-affix-vim|.
786Attempts have been made to keep this compatible with other spell checkers, so
787that the same files can often be used.  One other project that offers more
788than Myspell is Hunspell ( http://hunspell.sf.net ).
789
790
791WORD LIST FORMAT				*spell-dic-format*
792
793A short example, with line numbers:
794
795	1	1234 ~
796	2	aan ~
797	3	Als ~
798	4	Etten-Leur ~
799	5	et al. ~
800	6	's-Gravenhage ~
801	7	's-Gravenhaags ~
802	8	# word that differs between regions ~
803	9	kado/1 ~
804	10	cadeau/2 ~
805	11	TCP,IP ~
806	12	/the S affix may add a 's' ~
807	13	bedel/S ~
808
809The first line contains the number of words.  Vim ignores it, but you do get
810an error message if it's not there.  *E760*
811
812What follows is one word per line.  White space at the end of the line is
813ignored, all other white space matters.  The encoding is specified in the
814affix file |spell-SET|.
815
816Comment lines start with '#' or '/'.  See the example lines 8 and 12.  Note
817that putting a comment after a word is NOT allowed:
818
819		someword   # comment that causes an error! ~
820
821After the word there is an optional slash and flags.  Most of these flags are
822letters that indicate the affixes that can be used with this word.  These are
823specified with SFX and PFX lines in the .aff file, see |spell-SFX| and
824|spell-PFX|.  Vim allows using other flag types with the FLAG item in the
825affix file |spell-FLAG|.
826
827When the word only has lower-case letters it will also match with the word
828starting with an upper-case letter.
829
830When the word includes an upper-case letter, this means the upper-case letter
831is required at this position.  The same word with a lower-case letter at this
832position will not match. When some of the other letters are upper-case it will
833not match either.
834
835The word with all upper-case characters will always be OK,
836
837	word list	matches			does not match ~
838	als		als Als ALS		ALs AlS aLs aLS
839	Als		Als  ALS		als ALs AlS aLs aLS
840	ALS		ALS			als Als ALs AlS aLs aLS
841	AlS		AlS ALS			als Als ALs aLs aLS
842
843The KEEPCASE affix ID can be used to specifically match a word with identical
844case only, see below |spell-KEEPCASE|.
845
846Note: in line 5 to 7 non-word characters are used.  You can include any
847character in a word.  When checking the text a word still only matches when it
848appears with a non-word character before and after it.  For Myspell a word
849starting with a non-word character probably won't work.
850
851In line 12 the word "TCP/IP" is defined.  Since the slash has a special
852meaning the comma is used instead.  This is defined with the SLASH item in the
853affix file, see |spell-SLASH|.  Note that without this SLASH item the word
854will be "TCP,IP".
855
856
857AFFIX FILE FORMAT			*spell-aff-format* *spell-affix-vim*
858
859							*spell-affix-comment*
860Comment lines in the .aff file start with a '#':
861
862	# comment line ~
863
864Items with a fixed number of arguments can be followed by a comment.  But only
865if none of the arguments can contain white space.  The comment must start with
866a "#" character.  Example:
867
868	KEEPCASE =  # fix case for words with this flag ~
869
870
871ENCODING							*spell-SET*
872
873The affix file can be in any encoding that is supported by "iconv".  However,
874in some cases the current locale should also be set properly at the time
875|:mkspell| is invoked.  Adding FOL/LOW/UPP lines removes this requirement
876|spell-FOL|.
877
878The encoding should be specified before anything where the encoding matters.
879The encoding applies both to the affix file and the dictionary file.  It is
880done with a SET line:
881
882	SET utf-8 ~
883
884The encoding can be different from the value of the 'encoding' option at the
885time ":mkspell" is used.  Vim will then convert everything to 'encoding' and
886generate a spell file for 'encoding'.  If some of the used characters to not
887fit in 'encoding' you will get an error message.
888							*spell-affix-mbyte*
889When using a multi-byte encoding it's possible to use more different affix
890flags.  But Myspell doesn't support that, thus you may not want to use it
891anyway.  For compatibility use an 8-bit encoding.
892
893
894INFORMATION
895
896These entries in the affix file can be used to add information to the spell
897file.  There are no restrictions on the format, but they should be in the
898right encoding.
899
900				*spell-NAME* *spell-VERSION* *spell-HOME*
901				*spell-AUTHOR* *spell-EMAIL* *spell-COPYRIGHT*
902	NAME		Name of the language
903	VERSION		1.0.1  with fixes
904	HOME		http://www.myhome.eu
905	AUTHOR		John Doe
906	EMAIL		john AT Doe DOT net
907	COPYRIGHT	LGPL
908
909These fields are put in the .spl file as-is.  The |:spellinfo| command can be
910used to view the info.
911
912							*:spellinfo* *:spelli*
913:spelli[nfo]		Display the information for the spell file(s) used for
914			the current buffer.
915
916
917CHARACTER TABLES
918							*spell-affix-chars*
919When using an 8-bit encoding the affix file should define what characters are
920word characters.  This is because the system where ":mkspell" is used may not
921support a locale with this encoding and isalpha() won't work.  For example
922when using "cp1250" on Unix.
923						*E761* *E762* *spell-FOL*
924						*spell-LOW* *spell-UPP*
925Three lines in the affix file are needed.  Simplistic example:
926
927	FOL  áëñ ~
928	LOW  áëñ ~
929	UPP  ÁËÑ ~
930
931All three lines must have exactly the same number of characters.
932
933The "FOL" line specifies the case-folded characters.  These are used to
934compare words while ignoring case.  For most encodings this is identical to
935the lower case line.
936
937The "LOW" line specifies the characters in lower-case.  Mostly it's equal to
938the "FOL" line.
939
940The "UPP" line specifies the characters with upper-case.  That is, a character
941is upper-case where it's different from the character at the same position in
942"FOL".
943
944An exception is made for the German sharp s ß.  The upper-case version is
945"SS".  In the FOL/LOW/UPP lines it should be included, so that it's recognized
946as a word character, but use the ß character in all three.
947
948ASCII characters should be omitted, Vim always handles these in the same way.
949When the encoding is UTF-8 no word characters need to be specified.
950
951							*E763*
952Vim allows you to use spell checking for several languages in the same file.
953You can list them in the 'spelllang' option.  As a consequence all spell files
954for the same encoding must use the same word characters, otherwise they can't
955be combined without errors.
956
957If you get an E763 warning that the word tables differ you need to update your
958".spl" spell files.  If you downloaded the files, get the latest version of
959all spell files you use.  If you are only using one, e.g., German, then also
960download the recent English spell files.  Otherwise generate the .spl file
961again with |:mkspell|.  If you still get errors check the FOL, LOW and UPP
962lines in the used .aff files.
963
964The XX.ascii.spl spell file generated with the "-ascii" argument will not
965contain the table with characters, so that it can be combine with spell files
966for any encoding.  The .add.spl files also do not contain the table.
967
968
969MID-WORD CHARACTERS
970							*spell-midword*
971Some characters are only to be considered word characters if they are used in
972between two ordinary word characters.  An example is the single quote: It is
973often used to put text in quotes, thus it can't be recognized as a word
974character, but when it appears in between word characters it must be part of
975the word.  This is needed to detect a spelling error such as they'are.  That
976should be they're, but since "they" and "are" are words themselves that would
977go unnoticed.
978
979These characters are defined with MIDWORD in the .aff file.  Example:
980
981	MIDWORD	'- ~
982
983
984FLAG TYPES						*spell-FLAG*
985
986Flags are used to specify the affixes that can be used with a word and for
987other properties of the word.  Normally single-character flags are used.  This
988limits the number of possible flags, especially for 8-bit encodings.  The FLAG
989item can be used if more affixes are to be used.  Possible values:
990
991	FLAG long	use two-character flags
992	FLAG num	use numbers, from 1 up to 65000
993	FLAG caplong	use one-character flags without A-Z and two-character
994			flags that start with A-Z
995
996With "FLAG num" the numbers in a list of affixes need to be separated with a
997comma: "234,2143,1435".  This method is inefficient, but useful if the file is
998generated with a program.
999
1000When using "caplong" the two-character flags all start with a capital: "Aa",
1001"B1", "BB", etc.  This is useful to use one-character flags for the most
1002common items and two-character flags for uncommon items.
1003
1004Note: When using utf-8 only characters up to 65000 may be used for flags.
1005
1006Note: even when using "num" or "long" the number of flags available to
1007compounding and prefixes is limited to about 250.
1008
1009
1010AFFIXES
1011					    *spell-PFX* *spell-SFX*
1012The usual PFX (prefix) and SFX (suffix) lines are supported (see the Myspell
1013documentation or the Aspell manual:
1014http://aspell.net/man-html/Affix-Compression.html).
1015
1016Summary:
1017	SFX L Y 2 ~
1018	SFX L 0 re [^x] ~
1019	SFX L 0 ro x ~
1020
1021The first line is a header and has four fields:
1022	SFX {flag} {combine} {count}
1023
1024{flag}		The name used for the suffix.  Mostly it's a single letter,
1025		but other characters can be used, see |spell-FLAG|.
1026
1027{combine}	Can be 'Y' or 'N'.  When 'Y' then the word plus suffix can
1028		also have a prefix.  When 'N' then a prefix is not allowed.
1029
1030{count}		The number of lines following.  If this is wrong you will get
1031		an error message.
1032
1033For PFX the fields are exactly the same.
1034
1035The basic format for the following lines is:
1036	SFX {flag} {strip} {add} {condition} {extra}
1037
1038{flag}		Must be the same as the {flag} used in the first line.
1039
1040{strip}		Characters removed from the basic word.  There is no check if
1041		the characters are actually there, only the length is used (in
1042		bytes).  This better match the {condition}, otherwise strange
1043		things may happen.  If the {strip} length is equal to or
1044		longer than the basic word the suffix won't be used.
1045		When {strip} is 0 (zero) then nothing is stripped.
1046
1047{add}		Characters added to the basic word, after removing {strip}.
1048		Optionally there is a '/' followed by flags.  The flags apply
1049		to the word plus affix.  See |spell-affix-flags|
1050
1051{condition}	A simplistic pattern.  Only when this matches with a basic
1052		word will the suffix be used for that word.  This is normally
1053		for using one suffix letter with different {add} and {strip}
1054		fields for words with different endings.
1055		When {condition} is a . (dot) there is no condition.
1056		The pattern may contain:
1057		- Literal characters.
1058		- A set of characters in []. [abc] matches a, b and c.
1059		  A dash is allowed for a range [a-c], but this is
1060		  Vim-specific.
1061		- A set of characters that starts with a ^, meaning the
1062		  complement of the specified characters. [^abc] matches any
1063		  character but a, b and c.
1064
1065{extra}		Optional extra text:
1066		    # comment		Comment is ignored
1067		    -			Hunspell uses this, ignored
1068
1069For PFX the fields are the same, but the {strip}, {add} and {condition} apply
1070to the start of the word.
1071
1072Note: Myspell ignores any extra text after the relevant info.  Vim requires
1073this text to start with a "#" so that mistakes don't go unnoticed.  Example:
1074
1075	SFX F 0 in   [^i]n      # Spion > Spionin  ~
1076	SFX F 0 nen  in		# Bauerin > Bauerinnen ~
1077
1078However, to avoid lots of errors in affix files written for Myspell, you can
1079add the IGNOREEXTRA flag.
1080
1081Apparently Myspell allows an affix name to appear more than once.  Since this
1082might also be a mistake, Vim checks for an extra "S".  The affix files for
1083Myspell that use this feature apparently have this flag.  Example:
1084
1085	SFX a Y 1 S ~
1086	SFX a 0 an . ~
1087
1088	SFX a Y 2 S ~
1089	SFX a 0 en . ~
1090	SFX a 0 on . ~
1091
1092
1093AFFIX FLAGS						*spell-affix-flags*
1094
1095This is a feature that comes from Hunspell: The affix may specify flags.  This
1096works similar to flags specified on a basic word.  The flags apply to the
1097basic word plus the affix (but there are restrictions).  Example:
1098
1099	SFX S Y 1 ~
1100	SFX S 0 s . ~
1101
1102	SFX A Y 1 ~
1103	SFX A 0 able/S . ~
1104
1105When the dictionary file contains "drink/AS" then these words are possible:
1106
1107	drink
1108	drinks		uses S suffix
1109	drinkable	uses A suffix
1110	drinkables	uses A suffix and then S suffix
1111
1112Generally the flags of the suffix are added to the flags of the basic word,
1113both are used for the word plus suffix.  But the flags of the basic word are
1114only used once for affixes, except that both one prefix and one suffix can be
1115used when both support combining.
1116
1117Specifically, the affix flags can be used for:
1118- Suffixes on suffixes, as in the example above.  This works once, thus you
1119  can have two suffixes on a word (plus one prefix).
1120- Making the word with the affix rare, by using the |spell-RARE| flag.
1121- Exclude the word with the affix from compounding, by using the
1122  |spell-COMPOUNDFORBIDFLAG| flag.
1123- Allow the word with the affix to be part of a compound word on the side of
1124  the affix with the |spell-COMPOUNDPERMITFLAG|.
1125- Use the NEEDCOMPOUND flag: word plus affix can only be used as part of a
1126  compound word. |spell-NEEDCOMPOUND|
1127- Compound flags: word plus affix can be part of a compound word at the end,
1128  middle, start, etc.  The flags are combined with the flags of the basic
1129  word.  |spell-compound|
1130- NEEDAFFIX: another affix is needed to make a valid word.
1131- CIRCUMFIX, as explained just below.
1132
1133
1134IGNOREEXTRA						*spell-IGNOREEXTRA*
1135
1136Normally Vim gives an error for an extra field that does not start with '#'.
1137This avoids errors going unnoticed.  However, some files created for Myspell
1138or Hunspell may contain many entries with an extra field.  Use the IGNOREEXTRA
1139flag to avoid lots of errors.
1140
1141
1142CIRCUMFIX						*spell-CIRCUMFIX*
1143
1144The CIRCUMFIX flag means a prefix and suffix must be added at the same time.
1145If a prefix has the CIRCUMFIX flag than only suffixes with the CIRCUMFIX flag
1146can be added, and the other way around.
1147An alternative is to only specify the suffix, and give the that suffix two
1148flags: The required prefix and the NEEDAFFIX flag.  |spell-NEEDAFFIX|
1149
1150
1151PFXPOSTPONE						*spell-PFXPOSTPONE*
1152
1153When an affix file has very many prefixes that apply to many words it's not
1154possible to build the whole word list in memory.  This applies to Hebrew (a
1155list with all words is over a Gbyte).  In that case applying prefixes must be
1156postponed.  This makes spell checking slower.  It is indicated by this keyword
1157in the .aff file:
1158
1159	PFXPOSTPONE ~
1160
1161Only prefixes without a chop string and without flags can be postponed.
1162Prefixes with a chop string or with flags will still be included in the word
1163list.  An exception if the chop string is one character and equal to the last
1164character of the added string, but in lower case.  Thus when the chop string
1165is used to allow the following word to start with an upper case letter.
1166
1167
1168WORDS WITH A SLASH					*spell-SLASH*
1169
1170The slash is used in the .dic file to separate the basic word from the affix
1171letters and other flags.  Unfortunately, this means you cannot use a slash in
1172a word.  Thus "TCP/IP" is not a word but "TCP" with the flags "IP".  To include
1173a slash in the word put a backslash before it: "TCP\/IP".  In the rare case
1174you want to use a backslash inside a word you need to use two backslashes.
1175Any other use of the backslash is reserved for future expansion.
1176
1177
1178KEEP-CASE WORDS						*spell-KEEPCASE*
1179
1180In the affix file a KEEPCASE line can be used to define the affix name used
1181for keep-case words.  Example:
1182
1183	KEEPCASE = ~
1184
1185This flag is not supported by Myspell.  It has the meaning that case matters.
1186This can be used if the word does not have the first letter in upper case at
1187the start of a sentence.  Example:
1188
1189    word list	    matches		    does not match ~
1190    's morgens/=    's morgens		    'S morgens 's Morgens 'S MORGENS
1191    's Morgens	    's Morgens 'S MORGENS   'S morgens 's morgens
1192
1193The flag can also be used to avoid that the word matches when it is in all
1194upper-case letters.
1195
1196
1197RARE WORDS						*spell-RARE*
1198
1199In the affix file a RARE line can be used to define the affix name used for
1200rare words.  Example:
1201
1202	RARE ? ~
1203
1204Rare words are highlighted differently from bad words.  This is to be used for
1205words that are correct for the language, but are hardly ever used and could be
1206a typing mistake anyway.  When the same word is found as good it won't be
1207highlighted as rare.
1208
1209This flag can also be used on an affix, so that a basic word is not rare but
1210the basic word plus affix is rare |spell-affix-flags|.  However, if the word
1211also appears as a good word in another way (e.g., in another region) it won't
1212be marked as rare.
1213
1214
1215BAD WORDS						*spell-BAD*
1216
1217In the affix file a BAD line can be used to define the affix name used for
1218bad words.  Example:
1219
1220	BAD ! ~
1221
1222This can be used to exclude words that would otherwise be good.  For example
1223"the the" in the .dic file:
1224
1225	the the/! ~
1226
1227Once a word has been marked as bad it won't be undone by encountering the same
1228word as good.
1229
1230The flag also applies to the word with affixes, thus this can be used to mark
1231a whole bunch of related words as bad.
1232
1233							*spell-FORBIDDENWORD*
1234FORBIDDENWORD can be used just like BAD.  For compatibility with Hunspell.
1235
1236							*spell-NEEDAFFIX*
1237The NEEDAFFIX flag is used to require that a word is used with an affix.  The
1238word itself is not a good word (unless there is an empty affix).  Example:
1239
1240	NEEDAFFIX + ~
1241
1242
1243COMPOUND WORDS						*spell-compound*
1244
1245A compound word is a longer word made by concatenating words that appear in
1246the .dic file.  To specify which words may be concatenated a character is
1247used.  This character is put in the list of affixes after the word.  We will
1248call this character a flag here.  Obviously these flags must be different from
1249any affix IDs used.
1250
1251							*spell-COMPOUNDFLAG*
1252The Myspell compatible method uses one flag, specified with COMPOUNDFLAG.  All
1253words with this flag combine in any order.  This means there is no control
1254over which word comes first.  Example:
1255	COMPOUNDFLAG c ~
1256
1257							*spell-COMPOUNDRULE*
1258A more advanced method to specify how compound words can be formed uses
1259multiple items with multiple flags.  This is not compatible with Myspell 3.0.
1260Let's start with an example:
1261	COMPOUNDRULE c+ ~
1262	COMPOUNDRULE se ~
1263
1264The first line defines that words with the "c" flag can be concatenated in any
1265order.  The second line defines compound words that are made of one word with
1266the "s" flag and one word with the "e" flag.  With this dictionary:
1267	bork/c ~
1268	onion/s ~
1269	soup/e ~
1270
1271You can make these words:
1272	bork
1273	borkbork
1274	borkborkbork
1275	(etc.)
1276	onion
1277	soup
1278	onionsoup
1279
1280The COMPOUNDRULE item may appear multiple times.  The argument is made out of
1281one or more groups, where each group can be:
1282	one flag			e.g., c
1283	alternate flags inside []	e.g., [abc]
1284Optionally this may be followed by:
1285	*	the group appears zero or more times, e.g., sm*e
1286	+	the group appears one or more times, e.g., c+
1287	?	the group appears zero times or once, e.g., x?
1288
1289This is similar to the regexp pattern syntax (but not the same!).  A few
1290examples with the sequence of word flags they require:
1291    COMPOUNDRULE x+	    x xx xxx etc.
1292    COMPOUNDRULE yz	    yz
1293    COMPOUNDRULE x+z	    xz xxz xxxz etc.
1294    COMPOUNDRULE yx+	    yx yxx yxxx etc.
1295    COMPOUNDRULE xy?z	    xz xyz
1296
1297    COMPOUNDRULE [abc]z    az bz cz
1298    COMPOUNDRULE [abc]+z   az aaz abaz bz baz bcbz cz caz cbaz etc.
1299    COMPOUNDRULE a[xyz]+   ax axx axyz ay ayx ayzz az azy azxy etc.
1300    COMPOUNDRULE sm*e	    se sme smme smmme etc.
1301    COMPOUNDRULE s[xyz]*e  se sxe sxye sxyxe sye syze sze szye szyxe  etc.
1302
1303A specific example: Allow a compound to be made of two words and a dash:
1304	In the .aff file:
1305	    COMPOUNDRULE sde ~
1306	    NEEDAFFIX x ~
1307	    COMPOUNDWORDMAX 3 ~
1308	    COMPOUNDMIN 1 ~
1309	In the .dic file:
1310	    start/s ~
1311	    end/e ~
1312	    -/xd ~
1313
1314This allows for the word "start-end", but not "startend".
1315
1316An additional implied rule is that, without further flags, a word with a
1317prefix cannot be compounded after another word, and a word with a suffix
1318cannot be compounded with a following word.  Thus the affix cannot appear
1319on the inside of a compound word.  This can be changed with the
1320|spell-COMPOUNDPERMITFLAG|.
1321
1322							*spell-NEEDCOMPOUND*
1323The NEEDCOMPOUND flag is used to require that a word is used as part of a
1324compound word.  The word itself is not a good word.  Example:
1325
1326	NEEDCOMPOUND & ~
1327
1328							*spell-ONLYINCOMPOUND*
1329The ONLYINCOMPOUND does exactly the same as NEEDCOMPOUND.  Supported for
1330compatibility with Hunspell.
1331
1332							*spell-COMPOUNDMIN*
1333The minimal character length of a word used for compounding is specified with
1334COMPOUNDMIN.  Example:
1335	COMPOUNDMIN 5 ~
1336
1337When omitted there is no minimal length.  Obviously you could just leave out
1338the compound flag from short words instead, this feature is present for
1339compatibility with Myspell.
1340
1341							*spell-COMPOUNDWORDMAX*
1342The maximum number of words that can be concatenated into a compound word is
1343specified with COMPOUNDWORDMAX.  Example:
1344	COMPOUNDWORDMAX 3 ~
1345
1346When omitted there is no maximum.  It applies to all compound words.
1347
1348To set a limit for words with specific flags make sure the items in
1349COMPOUNDRULE where they appear don't allow too many words.
1350
1351							*spell-COMPOUNDSYLMAX*
1352The maximum number of syllables that a compound word may contain is specified
1353with COMPOUNDSYLMAX.  Example:
1354	COMPOUNDSYLMAX 6 ~
1355
1356This has no effect if there is no SYLLABLE item.  Without COMPOUNDSYLMAX there
1357is no limit on the number of syllables.
1358
1359If both COMPOUNDWORDMAX and COMPOUNDSYLMAX are defined, a compound word is
1360accepted if it fits one of the criteria, thus is either made from up to
1361COMPOUNDWORDMAX words or contains up to COMPOUNDSYLMAX syllables.
1362
1363						    *spell-COMPOUNDFORBIDFLAG*
1364The COMPOUNDFORBIDFLAG specifies a flag that can be used on an affix.  It
1365means that the word plus affix cannot be used in a compound word.  Example:
1366	affix file:
1367		COMPOUNDFLAG c ~
1368		COMPOUNDFORBIDFLAG x ~
1369		SFX a Y 2 ~
1370		SFX a 0 s   . ~
1371		SFX a 0 ize/x . ~
1372	dictionary:
1373		word/c ~
1374		util/ac ~
1375
1376This allows for "wordutil" and "wordutils" but not "wordutilize".
1377Note: this doesn't work for postponed prefixes yet.
1378
1379						    *spell-COMPOUNDPERMITFLAG*
1380The COMPOUNDPERMITFLAG specifies a flag that can be used on an affix.  It
1381means that the word plus affix can also be used in a compound word in a way
1382where the affix ends up halfway the word.  Without this flag that is not
1383allowed.
1384Note: this doesn't work for postponed prefixes yet.
1385
1386						    *spell-COMPOUNDROOT*
1387The COMPOUNDROOT flag is used for words in the dictionary that are already a
1388compound.  This means it counts for two words when checking the compounding
1389rules.  Can also be used for an affix to count the affix as a compounding
1390word.
1391
1392						*spell-CHECKCOMPOUNDPATTERN*
1393CHECKCOMPOUNDPATTERN is used to define patterns that, when matching at the
1394position where two words are compounded together forbids the compound.
1395For example:
1396	CHECKCOMPOUNDPATTERN o e ~
1397
1398This forbids compounding if the first word ends in "o" and the second word
1399starts with "e".
1400
1401The arguments must be plain text, no patterns are actually supported, despite
1402the item name.  Case is always ignored.
1403
1404The Hunspell feature to use three arguments and flags is not supported.
1405
1406							*spell-NOCOMPOUNDSUGS*
1407This item indicates that using compounding to make suggestions is not a good
1408idea.  Use this when compounding is used with very short or one-character
1409words.  E.g. to make numbers out of digits.  Without this flag creating
1410suggestions would spend most time trying all kind of weird compound words.
1411
1412	NOCOMPOUNDSUGS ~
1413
1414							*spell-SYLLABLE*
1415The SYLLABLE item defines characters or character sequences that are used to
1416count the number of syllables in a word.  Example:
1417	SYLLABLE aáeéiíoóöõuúüûy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui ~
1418
1419Before the first slash is the set of characters that are counted for one
1420syllable, also when repeated and mixed, until the next character that is not
1421in this set.  After the slash come sequences of characters that are counted
1422for one syllable.  These are preferred over using characters from the set.
1423With the example "ideeen" has three syllables, counted by "i", "ee" and "e".
1424
1425Only case-folded letters need to be included.
1426
1427Another way to restrict compounding was mentioned above: Adding the
1428|spell-COMPOUNDFORBIDFLAG| flag to an affix causes all words that are made
1429with that affix to not be used for compounding.
1430
1431
1432UNLIMITED COMPOUNDING					*spell-NOBREAK*
1433
1434For some languages, such as Thai, there is no space in between words.  This
1435looks like all words are compounded.  To specify this use the NOBREAK item in
1436the affix file, without arguments:
1437	NOBREAK ~
1438
1439Vim will try to figure out where one word ends and a next starts.  When there
1440are spelling mistakes this may not be quite right.
1441
1442
1443							*spell-COMMON*
1444Common words can be specified with the COMMON item.  This will give better
1445suggestions when editing a short file.  Example:
1446
1447	COMMON  the of to and a in is it you that he was for on are ~
1448
1449The words must be separated by white space, up to 25 per line.
1450When multiple regions are specified in a ":mkspell" command the common words
1451for all regions are combined and used for all regions.
1452
1453							*spell-NOSPLITSUGS*
1454This item indicates that splitting a word to make suggestions is not a good
1455idea.  Split-word suggestions will appear only when there are few similar
1456words.
1457
1458	NOSPLITSUGS ~
1459
1460							*spell-NOSUGGEST*
1461The flag specified with NOSUGGEST can be used for words that will not be
1462suggested.  Can be used for obscene words.
1463
1464	NOSUGGEST % ~
1465
1466
1467REPLACEMENTS						*spell-REP*
1468
1469In the affix file REP items can be used to define common mistakes.  This is
1470used to make spelling suggestions.  The items define the "from" text and the
1471"to" replacement.  Example:
1472
1473	REP 4 ~
1474	REP f ph ~
1475	REP ph f ~
1476	REP k ch ~
1477	REP ch k ~
1478
1479The first line specifies the number of REP lines following.  Vim ignores the
1480number, but it must be there (for compatibility with Myspell).
1481
1482Don't include simple one-character replacements or swaps.  Vim will try these
1483anyway.  You can include whole words if you want to, but you might want to use
1484the "file:" item in 'spellsuggest' instead.
1485
1486You can include a space by using an underscore:
1487
1488	REP the_the the ~
1489
1490
1491SIMILAR CHARACTERS					*spell-MAP* *E783*
1492
1493In the affix file MAP items can be used to define letters that are very much
1494alike.  This is mostly used for a letter with different accents.  This is used
1495to prefer suggestions with these letters substituted.  Example:
1496
1497	MAP 2 ~
1498	MAP eéëêè ~
1499	MAP uüùúû ~
1500
1501The first line specifies the number of MAP lines following.  Vim ignores the
1502number, but the line must be there.
1503
1504Each letter must appear in only one of the MAP items.  It's a bit more
1505efficient if the first letter is ASCII or at least one without accents.
1506
1507
1508.SUG FILE						*spell-NOSUGFILE*
1509
1510When soundfolding is specified in the affix file then ":mkspell" will normally
1511produce a .sug file next to the .spl file.  This file is used to find
1512suggestions by their sound-a-like form quickly.  At the cost of a lot of
1513memory (the amount depends on the number of words, |:mkspell| will display an
1514estimate when it's done).
1515
1516To avoid producing a .sug file use this item in the affix file:
1517
1518	NOSUGFILE ~
1519
1520Users can simply omit the .sug file if they don't want to use it.
1521
1522
1523SOUND-A-LIKE						*spell-SAL*
1524
1525In the affix file SAL items can be used to define the sounds-a-like mechanism
1526to be used.  The main items define the "from" text and the "to" replacement.
1527Simplistic example:
1528
1529	SAL CIA			 X ~
1530	SAL CH			 X ~
1531	SAL C			 K ~
1532	SAL K			 K ~
1533
1534There are a few rules and this can become quite complicated.  An explanation
1535how it works can be found in the Aspell manual:
1536http://aspell.net/man-html/Phonetic-Code.html.
1537
1538There are a few special items:
1539
1540	SAL followup		true ~
1541	SAL collapse_result	true ~
1542	SAL remove_accents	true ~
1543
1544"1" has the same meaning as "true".  Any other value means "false".
1545
1546
1547SIMPLE SOUNDFOLDING				*spell-SOFOFROM* *spell-SOFOTO*
1548
1549The SAL mechanism is complex and slow.  A simpler mechanism is mapping all
1550characters to another character, mapping similar sounding characters to the
1551same character.  At the same time this does case folding.  You can not have
1552both SAL items and simple soundfolding.
1553
1554There are two items required: one to specify the characters that are mapped
1555and one that specifies the characters they are mapped to.  They must have
1556exactly the same number of characters.  Example:
1557
1558    SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~
1559    SOFOTO   ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkes ~
1560
1561In the example all vowels are mapped to the same character 'e'.  Another
1562method would be to leave out all vowels.  Some characters that sound nearly
1563the same and are often mixed up, such as 'm' and 'n', are mapped to the same
1564character.  Don't do this too much, all words will start looking alike.
1565
1566Characters that do not appear in SOFOFROM will be left out, except that all
1567white space is replaced by one space.  Sequences of the same character in
1568SOFOFROM are replaced by one.
1569
1570You can use the |soundfold()| function to try out the results.  Or set the
1571'verbose' option to see the score in the output of the |z=| command.
1572
1573
1574UNSUPPORTED ITEMS				*spell-affix-not-supported*
1575
1576These items appear in the affix file of other spell checkers.  In Vim they are
1577ignored, not supported or defined in another way.
1578
1579ACCENT		(Hunspell)				*spell-ACCENT*
1580		Use MAP instead. |spell-MAP|
1581
1582BREAK		(Hunspell)				*spell-BREAK*
1583		Define break points.  Unclear how it works exactly.
1584		Not supported.
1585
1586CHECKCOMPOUNDCASE  (Hunspell)			*spell-CHECKCOMPOUNDCASE*
1587		Disallow uppercase letters at compound word boundaries.
1588		Not supported.
1589
1590CHECKCOMPOUNDDUP  (Hunspell)			*spell-CHECKCOMPOUNDDUP*
1591		Disallow using the same word twice in a compound.  Not
1592		supported.
1593
1594CHECKCOMPOUNDREP  (Hunspell)			*spell-CHECKCOMPOUNDREP*
1595		Something about using REP items and compound words.  Not
1596		supported.
1597
1598CHECKCOMPOUNDTRIPLE  (Hunspell)			*spell-CHECKCOMPOUNDTRIPLE*
1599		Forbid three identical characters when compounding.  Not
1600		supported.
1601
1602CHECKSHARPS  (Hunspell))			*spell-CHECKSHARPS*
1603		SS letter pair in uppercased (German) words may be upper case
1604		sharp s (ß). Not supported.
1605
1606COMPLEXPREFIXES  (Hunspell)				*spell-COMPLEXPREFIXES*
1607		Enables using two prefixes.  Not supported.
1608
1609COMPOUND	(Hunspell)				*spell-COMPOUND*
1610		This is one line with the count of COMPOUND items, followed by
1611		that many COMPOUND lines with a pattern.
1612		Remove the first line with the count and rename the other
1613		items to COMPOUNDRULE |spell-COMPOUNDRULE|
1614
1615COMPOUNDFIRST	(Hunspell)				*spell-COMPOUNDFIRST*
1616		Use COMPOUNDRULE instead. |spell-COMPOUNDRULE|
1617
1618COMPOUNDBEGIN	(Hunspell)				*spell-COMPOUNDBEGIN*
1619		Words signed with COMPOUNDBEGIN may be first elements in
1620		compound words.
1621		Use COMPOUNDRULE instead. |spell-COMPOUNDRULE|
1622
1623COMPOUNDLAST	(Hunspell)				*spell-COMPOUNDLAST*
1624		Words signed with COMPOUNDLAST may be last elements in
1625		compound words.
1626		Use COMPOUNDRULE instead. |spell-COMPOUNDRULE|
1627
1628COMPOUNDEND	(Hunspell)				*spell-COMPOUNDEND*
1629		Probably the same as COMPOUNDLAST
1630
1631COMPOUNDMIDDLE	(Hunspell)				*spell-COMPOUNDMIDDLE*
1632		Words signed with COMPOUNDMIDDLE may be middle elements in
1633		compound words.
1634		Use COMPOUNDRULE instead. |spell-COMPOUNDRULE|
1635
1636COMPOUNDRULES	(Hunspell)				*spell-COMPOUNDRULES*
1637		Number of COMPOUNDRULE lines following.  Ignored, but the
1638		argument must be a number.
1639
1640COMPOUNDSYLLABLE  (Hunspell)			*spell-COMPOUNDSYLLABLE*
1641		Use SYLLABLE and COMPOUNDSYLMAX instead. |spell-SYLLABLE|
1642		|spell-COMPOUNDSYLMAX|
1643
1644KEY		(Hunspell)				*spell-KEY*
1645		Define characters that are close together on the keyboard.
1646		Used to give better suggestions.  Not supported.
1647
1648LANG		(Hunspell)				*spell-LANG*
1649		This specifies language-specific behavior.  This actually
1650		moves part of the language knowledge into the program,
1651		therefore Vim does not support it.  Each language property
1652		must be specified separately.
1653
1654LEMMA_PRESENT	(Hunspell)				*spell-LEMMA_PRESENT*
1655		Only needed for morphological analysis.
1656
1657MAXNGRAMSUGS	(Hunspell)				*spell-MAXNGRAMSUGS*
1658		Set number of n-gram suggestions.  Not supported.
1659
1660PSEUDOROOT	(Hunspell)				*spell-PSEUDOROOT*
1661		Use NEEDAFFIX instead. |spell-NEEDAFFIX|
1662
1663SUGSWITHDOTS	(Hunspell)				*spell-SUGSWITHDOTS*
1664		Adds dots to suggestions.  Vim doesn't need this.
1665
1666SYLLABLENUM	(Hunspell)				*spell-SYLLABLENUM*
1667		Not supported.
1668
1669TRY		(Myspell, Hunspell, others)		*spell-TRY*
1670		Vim does not use the TRY item, it is ignored.  For making
1671		suggestions the actual characters in the words are used, that
1672		is much more efficient.
1673
1674WORDCHARS	(Hunspell)				*spell-WORDCHARS*
1675		Used to recognize words.  Vim doesn't need it, because there
1676		is no need to separate words before checking them (using a
1677		trie instead of a hashtable).
1678
1679 vim:tw=78:sw=4:ts=8:noet:ft=help:norl:
1680