robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqMerge pull request #40982 from zeertzjq/vim-e2d3e78d57cf6b4fc

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