242
|
1 *spell.txt* For Vim version 7.0aa. Last change: 2005 Apr 17
|
221
|
2
|
|
3
|
|
4 VIM REFERENCE MANUAL by Bram Moolenaar
|
|
5
|
|
6
|
|
7 Spell checking *spell*
|
|
8
|
|
9 1. Quick start |spell-quickstart|
|
237
|
10 2. Generating a spell file |spell-mkspell|
|
|
11 9. Spell file format |spell-file-format|
|
221
|
12
|
|
13 {Vi does not have any of these commands}
|
|
14
|
|
15 Spell checking is not available when the |+syntax| feature has been disabled
|
|
16 at compile time.
|
|
17
|
|
18 ==============================================================================
|
|
19 1. Quick start *spell-quickstart*
|
|
20
|
|
21 This command switches on spell checking: >
|
|
22
|
|
23 :setlocal spell spelllang=en_us
|
|
24
|
237
|
25 This switches on the 'spell' option and specifies to check for US English.
|
221
|
26
|
|
27 The words that are not recognized are highlighted with one of these:
|
|
28 SpellBad word not recognized
|
|
29 SpellRare rare word
|
|
30 SpellLocal wrong spelling for selected region
|
|
31
|
237
|
32 Vim only checks words for spelling, there is no grammar check.
|
|
33
|
|
34 To search for the next misspelled word:
|
|
35
|
|
36 *]s* *E756*
|
|
37 ]s Move to next misspelled word after the cursor.
|
|
38
|
|
39 *[s*
|
|
40 [s Move to next misspelled word before the cursor.
|
|
41 DOESN'T WORK YET!
|
|
42
|
221
|
43
|
227
|
44 PERFORMANCE
|
|
45
|
|
46 Note that Vim does on-the-fly spellchecking. To make this work fast the
|
237
|
47 word list is loaded in memory. Thus this uses a lot of memory (1 Mbyte or
|
227
|
48 more). There might also be a noticable delay when the word list is loaded,
|
|
49 which happens when 'spelllang' is set. Each word list is only loaded once,
|
|
50 they are not deleted when 'spelllang' is made empty. When 'encoding' is set
|
|
51 the word lists are reloaded, thus you may notice a delay then too.
|
|
52
|
|
53
|
221
|
54 REGIONS
|
|
55
|
|
56 A word may be spelled differently in various regions. For example, English
|
|
57 comes in (at least) these variants:
|
|
58
|
|
59 en all regions
|
|
60 en_us US
|
|
61 en_gb Great Britain
|
|
62 en_ca Canada
|
|
63
|
|
64 Words that are not used in one region but are used in another region are
|
|
65 highlighted with SpellLocal.
|
|
66
|
237
|
67 Always use lowercase letters for the language and region names.
|
221
|
68
|
|
69
|
|
70 SPELL FILES
|
|
71
|
|
72 Vim searches for spell files in the "spell" subdirectory of the directories in
|
237
|
73 'runtimepath'. The name is: LL-XXX.EEE.spl, where:
|
|
74 LL the language name
|
|
75 -XXX optional addition
|
|
76 EEE the value of 'encoding'
|
221
|
77
|
242
|
78 Exceptions:
|
|
79 - Vim uses "latin1" when 'encoding' is "iso-8859-15". The euro sign doesn't
|
|
80 matter for spelling.
|
|
81 - When no spell file for 'encoding' is found "ascii" is tried. This only
|
|
82 works for languages where nearly all words are ASCII, such as English. It
|
|
83 helps when 'encoding' is not "latin1", such as iso-8859-2, and English text
|
|
84 is being edited.
|
221
|
85
|
227
|
86 Spelling for EBCDIC is currently not supported.
|
|
87
|
237
|
88 A spell file might not be available in the current 'encoding'. See
|
|
89 |spell-mkspell| about how to create a spell file. Converting a spell file
|
242
|
90 with "iconv" will NOT work!
|
221
|
91
|
237
|
92 *E758* *E759*
|
|
93 When loading a spell file Vim checks that it is properly formatted. If you
|
242
|
94 get an error the file may be truncated, modified or intended for another Vim
|
|
95 version.
|
237
|
96
|
227
|
97
|
|
98 WORDS
|
|
99
|
|
100 Vim uses a fixed method to recognize a word. This is independent of
|
|
101 'iskeyword', so that it also works in help files and for languages that
|
|
102 include characters like '-' in 'iskeyword'. The word characters do depend on
|
|
103 'encoding'.
|
|
104
|
|
105 A word that starts with a digit is always ignored.
|
|
106
|
|
107
|
|
108 SYNTAX HIGHLIGHTING
|
|
109
|
|
110 Files that use syntax highlighting can specify where spell checking should be
|
|
111 done:
|
|
112
|
|
113 everywhere default
|
|
114 in specific items use "contains=@Spell"
|
|
115 everywhere but specific items use "contains=@NoSpell"
|
|
116
|
|
117 Note that mixing @Spell and @NoSpell doesn't make sense.
|
|
118
|
221
|
119 ==============================================================================
|
237
|
120 2. Generating a spell file *spell-mkspell*
|
|
121
|
|
122 Vim uses a binary file format for spelling. This greatly speeds up loading
|
|
123 the word list and keeps it small.
|
|
124
|
|
125 You can create a Vim spell file from the .aff and .dic files that Myspell
|
|
126 uses. Myspell is used by OpenOffice.org and Mozilla. You should be able to
|
|
127 find them here:
|
|
128 http://lingucomponent.openoffice.org/spell_dic.html
|
221
|
129
|
242
|
130 :mksp[ell] [-ascii] {outname} {inname} ... *:mksp* *:mkspell*
|
237
|
131 Generate spell file {outname}.spl from Myspell files
|
|
132 {inname}.aff and {inname}.dic.
|
242
|
133 When the [-ascii] argument is present, words with
|
|
134 non-ascii characters are skipped. The resulting file
|
|
135 ends in "ascii.spl". Otherwise the resulting file
|
|
136 ends in "ENC.spl", where ENC is the value of
|
|
137 'encoding'.
|
237
|
138 Multiple {inname} arguments can be given to combine
|
|
139 regions into one Vim spell file. Example: >
|
|
140 :mkspell ~/.vim/spell/en /tmp/en_US /tmp/en_CA /tmp/en_AU
|
|
141 < This combines the English word lists for US, CA and AU
|
|
142 into one en.spl file.
|
|
143 Up to eight regions can be combined. *E754* *755*
|
|
144
|
|
145 Since you might want to change the word list for use with Vim the following
|
|
146 procedure is recommended:
|
|
147
|
|
148 1. Obtain the xx_YY.aff and xx_YY.dic files from Myspell.
|
|
149 2. Make a copy of these files to xx_YY.orig.aff and xx_YY.orig.dic.
|
|
150 3. Change the xx_YY.aff and xx_YY.dic files to remove bad words, add missing
|
|
151 words, etc.
|
|
152 4. Use |:mkspell| to generate the Vim spell file and try it out.
|
221
|
153
|
237
|
154 When the Myspell files are updated you can merge the differences:
|
|
155 5. Obtain the new Myspell files as xx_YY.new.aff and xx_UU.new.dic.
|
|
156 6. Use Vimdiff to see what changed: >
|
|
157 vimdiff xx_YY.orig.dic xx_YY.new.dic
|
|
158 7. Take over the changes you like in xx_YY.dic.
|
|
159 You may also need to change xx_YY.aff.
|
|
160 8. Rename xx_YY.new.dic to xx_YY.orig.dic and xx_YY.new.aff to xx_YY.new.aff.
|
|
161
|
|
162 ==============================================================================
|
|
163 9. Spell file format *spell-file-format*
|
|
164
|
|
165 This is the format of the files that are used by the person who creates and
|
|
166 maintains a word list.
|
221
|
167
|
237
|
168 Note that we avoid the word "dictionary" here. That is because the goal of
|
|
169 spell checking differs from writing a dictionary (as in the book). For
|
|
170 spelling we need a list of words that are OK, thus need not to be highlighted.
|
|
171 Names will not appear in a dictionary, but do appear in a word list. And
|
|
172 some old words are rarely used and are common misspellings. These do appear
|
|
173 in a dictionary but not in a word list.
|
|
174
|
|
175 There are two files: the basic word list and an affix file. The affixes are
|
|
176 used to modify the basic words to get the full word list. This significantly
|
|
177 reduces the number of words, especially for a language like Polish. This is
|
|
178 called affix compression.
|
221
|
179
|
237
|
180 The format for the affix and word list files is mostly identical to what
|
|
181 Myspell uses (the spell checker of Mozilla and OpenOffice.org). A description
|
|
182 can be found here:
|
|
183 http://lingucomponent.openoffice.org/affix.readme ~
|
|
184 Note that affixes are case sensitive, this isn't obvious from the description.
|
|
185 Vim supports a few extras. Hopefully Myspell will support these too some day.
|
|
186 See |spell-affix-vim|.
|
|
187
|
|
188 The basic word list and the affix file are combined and turned into a binary
|
|
189 spell file. All the preprocessing has been done, thus this file loads fast.
|
|
190 The binary spell file format is described in the source code (src/spell.c).
|
|
191 But only developers need to know about it.
|
221
|
192
|
237
|
193 The preprocessing also allows us to take the Myspell language files and modify
|
|
194 them before the Vim word list is made. The tools for this can be found in the
|
|
195 "src/spell" directory.
|
|
196
|
|
197
|
|
198 WORD LIST FORMAT *spell-wordlist-format*
|
|
199
|
|
200 A very short example, with line numbers:
|
221
|
201
|
237
|
202 1 1234
|
|
203 2 aan
|
|
204 3 Als
|
|
205 4 Etten-Leur
|
|
206 5 et al.
|
|
207 6 's-Gravenhage
|
|
208 7 's-Gravenhaags
|
|
209 8 bedel/P
|
|
210 9 kado/1
|
|
211 10 cadeau/2
|
|
212
|
|
213 The first line contains the number of words. Vim ignores it. *E760*
|
221
|
214
|
237
|
215 What follows is one word per line. There should be no white space after the
|
|
216 word.
|
|
217
|
|
218 When the word only has lower-case letters it will also match with the word
|
|
219 starting with an upper-case letter.
|
|
220
|
|
221 When the word includes an upper-case letter, this means the upper-case letter
|
|
222 is required at this position. The same word with a lower-case letter at this
|
|
223 position will not match. When some of the other letters are upper-case it will
|
|
224 not match either.
|
|
225
|
|
226 The same word with all upper-case characters will always be OK.
|
221
|
227
|
237
|
228 word list matches does not match ~
|
|
229 als als Als ALS ALs AlS aLs aLS
|
|
230 Als Als ALS als ALs AlS aLs aLS
|
|
231 ALS ALS als Als ALs AlS aLs aLS
|
|
232 AlS AlS ALS als Als ALs aLs aLS
|
221
|
233
|
237
|
234 Note in line 5 to 7 that non-word characters are used. You can include
|
|
235 any character in a word. When checking the text a word still only matches
|
|
236 when it appears with a non-word character before and after it. For Myspell a
|
|
237 word starting with a non-word character probably won't work.
|
|
238
|
|
239 After the word there is an optional slash and flags. Most of these flags are
|
|
240 letters that indicate the affixes that can be used with this word.
|
221
|
241
|
237
|
242 *spell-affix-vim*
|
|
243 A flag that Vim adds and is not in Myspell is the "=" flag. This has the
|
|
244 meaning that case matters. This can be used if the word does not have the
|
|
245 first letter in upper case at the start of a sentence. Example:
|
|
246
|
|
247 word list matches does not match ~
|
|
248 's morgens/= 's morgens 'S morgens 's Morgens
|
|
249 's Morgens 's Morgens 'S morgens 's morgens
|
221
|
250
|
237
|
251 *spell-affix-mbyte*
|
|
252 The basic word list is normally in an 8-bit encoding, which is mentioned in
|
|
253 the affix file. The affix file must always be in the same encoding as the
|
|
254 word list. This is compatible with Myspell. For Vim the encoding may also be
|
|
255 something else, any encoding that "iconv" supports. The "SET" line must
|
|
256 specify the name of the encoding. When using a multi-byte encoding it's
|
|
257 possible to use more different affixes.
|
221
|
258
|
237
|
259 Performance hint: Although using affixes reduces the number of words, it
|
|
260 reduces the speed. It's a good idea to put all the often used words in the
|
|
261 word list with the affixes prepended/appended.
|
221
|
262
|
|
263
|
|
264 vim:tw=78:sw=4:ts=8:ft=help:norl:
|