Bram Moolenaar | d857f0e | 2005-06-21 22:37:39 +0000 | [diff] [blame] | 1 | *spell.txt* For Vim version 7.0aa. Last change: 2005 Jun 21 |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 2 | |
| 3 | |
| 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
| 5 | |
| 6 | |
| 7 | Spell checking *spell* |
| 8 | |
| 9 | 1. Quick start |spell-quickstart| |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 10 | 2. Generating a spell file |spell-mkspell| |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 11 | 3. Spell file format |spell-file-format| |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 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 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 25 | This switches on the 'spell' option and specifies to check for US English. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 26 | |
| 27 | The words that are not recognized are highlighted with one of these: |
Bram Moolenaar | 520470a | 2005-06-16 21:59:56 +0000 | [diff] [blame] | 28 | SpellBad word not recognized |hl-SpellBad| |
| 29 | SpellRare rare word |hl-SpellRare| |
| 30 | SpellLocal wrong spelling for selected region |hl-SpellLocal| |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 31 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 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. |
Bram Moolenaar | 9d0ec2e | 2005-04-20 19:45:58 +0000 | [diff] [blame] | 38 | A count before the command can be used to repeat. |
| 39 | This uses the @Spell and @NoSpell clusters from syntax |
| 40 | highlighting, see |spell-syntax|. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 41 | |
| 42 | *[s* |
Bram Moolenaar | 9d0ec2e | 2005-04-20 19:45:58 +0000 | [diff] [blame] | 43 | [s Like "]s" but search backwards, find the misspelled |
| 44 | word before the cursor. |
| 45 | |
| 46 | *]S* |
| 47 | ]S Like "]s" but only stop at bad words, not at rare |
| 48 | words or words for another region. |
| 49 | |
| 50 | *[S* |
| 51 | [S Like "]S" but search backwards. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 52 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 53 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 54 | To add words to your own word list: *E764* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 55 | |
| 56 | *zg* |
| 57 | zg Add word under the cursor as a good word to |
| 58 | 'spellfile'. In Visual mode the selected characters |
| 59 | are added as a word (including white space!). |
| 60 | |
| 61 | *zw* |
| 62 | zw Add word under the cursor as a wrong (bad) word to |
| 63 | 'spellfile'. In Visual mode the selected characters |
| 64 | are added as a word (including white space!). |
| 65 | |
Bram Moolenaar | 520470a | 2005-06-16 21:59:56 +0000 | [diff] [blame] | 66 | *:spe* *:spellgood* |
| 67 | :spe[llgood] {word} Add [word} as a good word to 'spellfile'. |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 68 | |
Bram Moolenaar | 520470a | 2005-06-16 21:59:56 +0000 | [diff] [blame] | 69 | *:spellw* *:spellwrong* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 70 | :spellw[rong] {word} Add [word} as a wrong (bad) word to 'spellfile'. |
| 71 | |
| 72 | After adding a word to 'spellfile' its associated ".spl" file will |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 73 | automatically be updated. More details about the 'spellfile' format below |
| 74 | |spell-wordlist-format|. |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 75 | |
| 76 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 77 | Finding suggestions for bad words: |
| 78 | |
| 79 | *z?* |
| 80 | z? For the badly spelled word under the cursor suggest |
| 81 | the correctly spelled word. |
| 82 | When there is no badly spelled word under the cursor |
| 83 | use the one after the cursor, in the same line. |
| 84 | The results are sorted on similarity to the badly |
| 85 | spelled word. |
| 86 | This may take a long time. Hit CTRL-C when you are |
| 87 | bored. |
| 88 | You can enter the number of your choice or press |
| 89 | <Enter> if you don't want to replace. |
Bram Moolenaar | f3bd51a | 2005-06-14 22:11:18 +0000 | [diff] [blame] | 90 | If 'verbose' is non-zero a score will be displayed to |
| 91 | indicate the likeliness to the badly spelled word (the |
| 92 | higher the score the more different). |
| 93 | The score may be slightly wrong for words with |
| 94 | multi-byte characters. |
Bram Moolenaar | d857f0e | 2005-06-21 22:37:39 +0000 | [diff] [blame] | 95 | When a word was replaced the redo command "." will |
| 96 | repeat the word replacement. This works like "ciw", |
| 97 | the good word and <Esc>. |
| 98 | |
| 99 | The 'spellsuggest' option influences how the list of suggestions is generated |
| 100 | and sorted. See |'spellsuggest'|. |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 101 | |
| 102 | |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 103 | PERFORMANCE |
| 104 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 105 | Note that Vim does on-the-fly spell checking. To make this work fast the |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 106 | word list is loaded in memory. Thus this uses a lot of memory (1 Mbyte or |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 107 | more). There might also be a noticeable delay when the word list is loaded, |
| 108 | which happens when 'spelllang' or 'spell' is set. Each word list is only |
| 109 | loaded once, they are not deleted when 'spelllang' is made empty or 'spell' is |
| 110 | reset. When 'encoding' is set the word lists are reloaded, thus you may |
| 111 | notice a delay then too. |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 112 | |
| 113 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 114 | REGIONS |
| 115 | |
| 116 | A word may be spelled differently in various regions. For example, English |
| 117 | comes in (at least) these variants: |
| 118 | |
| 119 | en all regions |
Bram Moolenaar | 5c5474b | 2005-04-19 21:40:26 +0000 | [diff] [blame] | 120 | en_au Australia |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 121 | en_ca Canada |
Bram Moolenaar | 5c5474b | 2005-04-19 21:40:26 +0000 | [diff] [blame] | 122 | en_gb Great Britain |
| 123 | en_nz New Zealand |
| 124 | en_us USA |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 125 | |
| 126 | Words that are not used in one region but are used in another region are |
Bram Moolenaar | 520470a | 2005-06-16 21:59:56 +0000 | [diff] [blame] | 127 | highlighted with SpellLocal |hl-SpellLocal|. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 128 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 129 | Always use lowercase letters for the language and region names. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 130 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 131 | When adding a word with |zg| or another command it's always added for all |
| 132 | regions. You can change that by manually editing the 'spellfile'. See |
| 133 | |spell-wordlist-format|. |
| 134 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 135 | |
| 136 | SPELL FILES |
| 137 | |
| 138 | Vim searches for spell files in the "spell" subdirectory of the directories in |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 139 | 'runtimepath'. The name is: LL.EEE.spl, where: |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 140 | LL the language name |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 141 | EEE the value of 'encoding' |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 142 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 143 | Only the first file is loaded, the one that is first in 'runtimepath'. If |
| 144 | this succeeds then additionally files with the name LL.EEE.add.spl are loaded. |
| 145 | All the ones that are found are used. |
| 146 | |
Bram Moolenaar | 0e21a3f | 2005-04-17 20:28:32 +0000 | [diff] [blame] | 147 | Exceptions: |
| 148 | - Vim uses "latin1" when 'encoding' is "iso-8859-15". The euro sign doesn't |
| 149 | matter for spelling. |
| 150 | - When no spell file for 'encoding' is found "ascii" is tried. This only |
| 151 | works for languages where nearly all words are ASCII, such as English. It |
| 152 | helps when 'encoding' is not "latin1", such as iso-8859-2, and English text |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 153 | is being edited. For the ".add" files the same name as the found main |
| 154 | spell file is used. |
| 155 | |
| 156 | For example, with these values: |
| 157 | 'runtimepath' is "~/.vim,/usr/share/vim70,~/.vim/after" |
| 158 | 'encoding' is "iso-8859-2" |
| 159 | 'spelllang' is "pl" |
| 160 | |
| 161 | Vim will look for: |
| 162 | 1. ~/.vim/spell/pl.iso-8859-2.spl |
| 163 | 2. /usr/share/vim70/spell/pl.iso-8859-2.spl |
| 164 | 3. ~/.vim/spell/pl.iso-8859-2.add.spl |
| 165 | 4. /usr/share/vim70/spell/pl.iso-8859-2.add.spl |
| 166 | 5. ~/.vim/after/spell/pl.iso-8859-2.add.spl |
| 167 | |
| 168 | This assumes 1. is not found and 2. is found. |
| 169 | |
| 170 | If 'encoding' is "latin1" Vim will look for: |
| 171 | 1. ~/.vim/spell/pl.latin1.spl |
| 172 | 2. /usr/share/vim70/spell/pl.latin1.spl |
| 173 | 3. ~/.vim/after/spell/pl.latin1.spl |
| 174 | 4. ~/.vim/spell/pl.ascii.spl |
| 175 | 5. /usr/share/vim70/spell/pl.ascii.spl |
| 176 | 6. ~/.vim/after/spell/pl.ascii.spl |
| 177 | |
| 178 | This assumes none of them are found (Polish doesn't make sense when leaving |
| 179 | out the non-ASCII characters). |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 180 | |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 181 | Spelling for EBCDIC is currently not supported. |
| 182 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 183 | A spell file might not be available in the current 'encoding'. See |
| 184 | |spell-mkspell| about how to create a spell file. Converting a spell file |
Bram Moolenaar | 0e21a3f | 2005-04-17 20:28:32 +0000 | [diff] [blame] | 185 | with "iconv" will NOT work! |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 186 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 187 | *E758* *E759* |
| 188 | When loading a spell file Vim checks that it is properly formatted. If you |
Bram Moolenaar | 0e21a3f | 2005-04-17 20:28:32 +0000 | [diff] [blame] | 189 | get an error the file may be truncated, modified or intended for another Vim |
| 190 | version. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 191 | |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 192 | |
| 193 | WORDS |
| 194 | |
| 195 | Vim uses a fixed method to recognize a word. This is independent of |
| 196 | 'iskeyword', so that it also works in help files and for languages that |
| 197 | include characters like '-' in 'iskeyword'. The word characters do depend on |
| 198 | 'encoding'. |
| 199 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 200 | The table with word characters is stored in the main .spl file. Therefore it |
| 201 | matters what the current locale is when generating it! A .add.spl file does |
| 202 | not contain a word table. |
| 203 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 204 | A word that starts with a digit is always ignored. That includes hex numbers |
| 205 | in the form 0xff and 0XFF. |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 206 | |
| 207 | |
Bram Moolenaar | 9d0ec2e | 2005-04-20 19:45:58 +0000 | [diff] [blame] | 208 | SYNTAX HIGHLIGHTING *spell-syntax* |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 209 | |
| 210 | Files that use syntax highlighting can specify where spell checking should be |
| 211 | done: |
| 212 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 213 | 1. everywhere default |
| 214 | 2. in specific items use "contains=@Spell" |
| 215 | 3. everywhere but specific items use "contains=@NoSpell" |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 216 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 217 | For the second method adding the @NoSpell cluster will disable spell checking |
| 218 | again. This can be used, for example, to add @Spell to the comments of a |
| 219 | program, and add @NoSpell for items that shouldn't be checked. |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 220 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 221 | ============================================================================== |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 222 | 2. Generating a spell file *spell-mkspell* |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 223 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 224 | Vim uses a binary file format for spelling. This greatly speeds up loading |
| 225 | the word list and keeps it small. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 226 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 227 | You can create a Vim spell file from the .aff and .dic files that Myspell |
| 228 | uses. Myspell is used by OpenOffice.org and Mozilla. You should be able to |
| 229 | find them here: |
| 230 | http://lingucomponent.openoffice.org/spell_dic.html |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 231 | You can also use a plain word list. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 232 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 233 | Make sure your current locale is set properly, otherwise Vim doesn't know what |
| 234 | characters are upper/lower case letters. If the locale isn't available (e.g., |
| 235 | when using an MS-Windows codepage on Unix) add tables to the .aff file |
| 236 | |spell-affix-chars|. |
| 237 | |
Bram Moolenaar | 520470a | 2005-06-16 21:59:56 +0000 | [diff] [blame] | 238 | :mksp[ell][!] [-ascii] {outname} {inname} ... *:mksp* *:mkspell* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 239 | Generate a Vim spell file word lists. Example: > |
| 240 | :mkspell nl nl_NL.words |
| 241 | < |
| 242 | When {outname} ends in ".spl" it is used as the output |
| 243 | file name. Otherwise it should be a language name, |
| 244 | such as "en". The file written will be |
| 245 | {outname}.{encoding}.spl. {encoding} is the value of |
| 246 | the 'encoding' option. |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 247 | |
Bram Moolenaar | 520470a | 2005-06-16 21:59:56 +0000 | [diff] [blame] | 248 | When the output file already exists [!] must be added |
| 249 | to overwrite it. |
| 250 | |
Bram Moolenaar | 0e21a3f | 2005-04-17 20:28:32 +0000 | [diff] [blame] | 251 | When the [-ascii] argument is present, words with |
| 252 | non-ascii characters are skipped. The resulting file |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 253 | ends in "ascii.spl". |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 254 | |
| 255 | The input can be the Myspell format files {inname}.aff |
| 256 | and {inname}.dic. If {inname}.aff does not exist then |
| 257 | {inname} is used as the file name of a plain word |
| 258 | list. |
| 259 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 260 | Multiple {inname} arguments can be given to combine |
| 261 | regions into one Vim spell file. Example: > |
| 262 | :mkspell ~/.vim/spell/en /tmp/en_US /tmp/en_CA /tmp/en_AU |
| 263 | < This combines the English word lists for US, CA and AU |
| 264 | into one en.spl file. |
| 265 | Up to eight regions can be combined. *E754* *755* |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 266 | The REP and SAL items of the first .aff file where |
| 267 | they appear are used. |spell-affix-REP| |
| 268 | |spell-affix-SAL| |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 269 | |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 270 | When the spell file was written all currently used |
| 271 | spell files will be reloaded. |
| 272 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 273 | :mksp[ell] [-ascii] {add-name} |
| 274 | Like ":mkspell" above, using {add-name} as the input |
| 275 | file and producing an output file that has ".spl" |
| 276 | appended. |
| 277 | |
| 278 | Since you might want to change a Myspell word list for use with Vim the |
| 279 | following procedure is recommended: |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 280 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 281 | 1. Obtain the xx_YY.aff and xx_YY.dic files from Myspell. |
| 282 | 2. Make a copy of these files to xx_YY.orig.aff and xx_YY.orig.dic. |
| 283 | 3. Change the xx_YY.aff and xx_YY.dic files to remove bad words, add missing |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 284 | words, define word characters with FOL/LOW/UPP, etc. The distributed |
| 285 | "src/spell/*.diff" files can be used. |
| 286 | 4. Set 'encoding' to the desired encoding and use |:mkspell| to generate the |
| 287 | Vim spell file. |
| 288 | 5. Try out the spell file with ":set spell spelllang=xx_YY". |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 289 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 290 | When the Myspell files are updated you can merge the differences: |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 291 | 1. Obtain the new Myspell files as xx_YY.new.aff and xx_UU.new.dic. |
| 292 | 2. Use Vimdiff to see what changed: > |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 293 | vimdiff xx_YY.orig.dic xx_YY.new.dic |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 294 | 3. Take over the changes you like in xx_YY.dic. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 295 | You may also need to change xx_YY.aff. |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 296 | 4. Rename xx_YY.new.dic to xx_YY.orig.dic and xx_YY.new.aff to xx_YY.new.aff. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 297 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 298 | ============================================================================== |
| 299 | 9. Spell file format *spell-file-format* |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 300 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 301 | This is the format of the files that are used by the person who creates and |
| 302 | maintains a word list. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 303 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 304 | Note that we avoid the word "dictionary" here. That is because the goal of |
| 305 | spell checking differs from writing a dictionary (as in the book). For |
| 306 | spelling we need a list of words that are OK, thus need not to be highlighted. |
| 307 | Names will not appear in a dictionary, but do appear in a word list. And |
| 308 | some old words are rarely used and are common misspellings. These do appear |
| 309 | in a dictionary but not in a word list. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 310 | |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 311 | There are two formats: one with affix compression and one without. The files |
| 312 | with affix compression are used by Myspell (Mozilla and OpenOffice.org). This |
| 313 | requires two files, one with .aff and one with .dic extension. The second |
| 314 | format is a list of words. |
| 315 | |
| 316 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 317 | FORMAT OF WORD LIST *spell-wordlist-format* |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 318 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 319 | The words must appear one per line. That is all that is required. |
| 320 | Additionally the following items are recognized: |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 321 | - Empty and blank lines are ignored. |
| 322 | - Lines starting with a # are ignored (comment lines). |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 323 | - A line starting with "/encoding=", before any word, specifies the encoding |
| 324 | of the file. After the second '=' comes an encoding name. This tells Vim |
| 325 | to setup conversion from the specified encoding to 'encoding'. |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 326 | - A line starting with "/regions=" specifies the region names that are |
| 327 | supported. Each region name must be two ASCII letters. The first one is |
| 328 | region 1. Thus "/regions=usca" has region 1 "us" and region 2 "ca". |
| 329 | In an addition word list the list should be equal to the main word list! |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 330 | - A line starting with "/?" specifies a word that should be marked as rare. |
| 331 | - A line starting with "/!" specifies a word that should be marked as bad. |
| 332 | - A line starting with "/=" specifies a word where case must match exactly. |
| 333 | A "?" or "!" may be following: "/=?" and "/=!". |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 334 | - Digits after "/" indicate the regions in which the word is valid. If no |
| 335 | regions are specified the word is valid in all regions. |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 336 | - Other lines starting with '/' are reserved for future use. The ones that |
| 337 | are not recognized are ignored (but you do get a warning message). |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 338 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 339 | Example: |
| 340 | |
| 341 | # This is an example word list comment |
| 342 | /encoding=latin1 encoding of the file |
| 343 | /regions=uscagb regions "us", "ca" and "gb" |
| 344 | example word for all regions |
| 345 | /1blah word for region 1 "us" |
Bram Moolenaar | d857f0e | 2005-06-21 22:37:39 +0000 | [diff] [blame] | 346 | /!vim bad word |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 347 | /?3Campbell rare word in region 3 "gb" |
| 348 | /='s mornings keep-case word |
| 349 | |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 350 | |
| 351 | FORMAT WITH AFFIX COMPRESSION |
| 352 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 353 | There are two files: the basic word list and an affix file. The affixes are |
| 354 | used to modify the basic words to get the full word list. This significantly |
| 355 | reduces the number of words, especially for a language like Polish. This is |
| 356 | called affix compression. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 357 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 358 | The format for the affix and word list files is mostly identical to what |
| 359 | Myspell uses (the spell checker of Mozilla and OpenOffice.org). A description |
| 360 | can be found here: |
| 361 | http://lingucomponent.openoffice.org/affix.readme ~ |
| 362 | Note that affixes are case sensitive, this isn't obvious from the description. |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 363 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 364 | Vim supports a few extras. Hopefully Myspell will support these too some day. |
| 365 | See |spell-affix-vim|. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 366 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 367 | The basic word list and the affix file are combined and turned into a binary |
| 368 | spell file. All the preprocessing has been done, thus this file loads fast. |
| 369 | The binary spell file format is described in the source code (src/spell.c). |
| 370 | But only developers need to know about it. |
| 371 | |
| 372 | The preprocessing also allows us to take the Myspell language files and modify |
| 373 | them before the Vim word list is made. The tools for this can be found in the |
| 374 | "src/spell" directory. |
| 375 | |
| 376 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 377 | WORD LIST FORMAT *spell-dic-format* |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 378 | |
| 379 | A very short example, with line numbers: |
| 380 | |
| 381 | 1 1234 |
| 382 | 2 aan |
| 383 | 3 Als |
| 384 | 4 Etten-Leur |
| 385 | 5 et al. |
| 386 | 6 's-Gravenhage |
| 387 | 7 's-Gravenhaags |
| 388 | 8 bedel/P |
| 389 | 9 kado/1 |
| 390 | 10 cadeau/2 |
| 391 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 392 | The first line contains the number of words. Vim ignores it, but you do get |
| 393 | an error message if it's not there. *E760* |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 394 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 395 | What follows is one word per line. There should be no white space before or |
| 396 | after the word. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 397 | |
| 398 | When the word only has lower-case letters it will also match with the word |
| 399 | starting with an upper-case letter. |
| 400 | |
| 401 | When the word includes an upper-case letter, this means the upper-case letter |
| 402 | is required at this position. The same word with a lower-case letter at this |
| 403 | position will not match. When some of the other letters are upper-case it will |
| 404 | not match either. |
| 405 | |
| 406 | The same word with all upper-case characters will always be OK. |
| 407 | |
| 408 | word list matches does not match ~ |
| 409 | als als Als ALS ALs AlS aLs aLS |
| 410 | Als Als ALS als ALs AlS aLs aLS |
| 411 | ALS ALS als Als ALs AlS aLs aLS |
| 412 | AlS AlS ALS als Als ALs aLs aLS |
| 413 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 414 | The KEP affix ID can be used to specifically match a word with identical case |
Bram Moolenaar | e756604 | 2005-06-17 22:00:15 +0000 | [diff] [blame] | 415 | only, see below |spell-affix-KEP|. |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 416 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 417 | Note in line 5 to 7 that non-word characters are used. You can include |
| 418 | any character in a word. When checking the text a word still only matches |
| 419 | when it appears with a non-word character before and after it. For Myspell a |
| 420 | word starting with a non-word character probably won't work. |
| 421 | |
| 422 | After the word there is an optional slash and flags. Most of these flags are |
| 423 | letters that indicate the affixes that can be used with this word. |
| 424 | |
| 425 | *spell-affix-vim* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 426 | A flag that Vim adds and is not in Myspell is the flag defined with KEP in the |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 427 | affix file. This has the meaning that case matters. This can be used if the |
| 428 | word does not have the first letter in upper case at the start of a sentence. |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 429 | Example (assuming that = was used for KEP): |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 430 | |
| 431 | word list matches does not match ~ |
| 432 | 's morgens/= 's morgens 'S morgens 's Morgens |
| 433 | 's Morgens 's Morgens 'S morgens 's morgens |
| 434 | |
| 435 | *spell-affix-mbyte* |
| 436 | The basic word list is normally in an 8-bit encoding, which is mentioned in |
| 437 | the affix file. The affix file must always be in the same encoding as the |
| 438 | word list. This is compatible with Myspell. For Vim the encoding may also be |
| 439 | something else, any encoding that "iconv" supports. The "SET" line must |
| 440 | specify the name of the encoding. When using a multi-byte encoding it's |
| 441 | possible to use more different affixes. |
| 442 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 443 | |
| 444 | CHARACTER TABLES |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 445 | *spell-affix-chars* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 446 | When using an 8-bit encoding the affix file should define what characters are |
| 447 | word characters (as specified with ENC). This is because the system where |
| 448 | ":mkspell" is used may not support a locale with this encoding and isalpha() |
| 449 | won't work. For example when using "cp1250" on Unix. |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 450 | |
Bram Moolenaar | e756604 | 2005-06-17 22:00:15 +0000 | [diff] [blame] | 451 | *E761* *E762* *spell-affix-FOL* |
| 452 | *spell-affix-LOW* *spell-affix-UPP* |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 453 | Three lines in the affix file are needed. Simplistic example: |
| 454 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 455 | FOL áëñ ~ |
| 456 | LOW áëñ ~ |
| 457 | UPP ÁËÑ ~ |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 458 | |
| 459 | All three lines must have exactly the same number of characters. |
| 460 | |
| 461 | The "FOL" line specifies the case-folded characters. These are used to |
| 462 | compare words while ignoring case. For most encodings this is identical to |
| 463 | the lower case line. |
| 464 | |
| 465 | The "LOW" line specifies the characters in lower-case. Mostly it's equal to |
| 466 | the "FOL" line. |
| 467 | |
| 468 | The "UPP" line specifies the characters with upper-case. That is, a character |
| 469 | is upper-case where it's different from the character at the same position in |
| 470 | "FOL". |
| 471 | |
| 472 | ASCII characters should be omitted, Vim always handles these in the same way. |
| 473 | When the encoding is UTF-8 no word characters need to be specified. |
| 474 | |
| 475 | *E763* |
| 476 | All spell files for the same encoding must use the same word characters, |
Bram Moolenaar | 46df82e | 2005-04-24 22:06:24 +0000 | [diff] [blame] | 477 | otherwise they can't be combined without errors. The XX.ascii.spl spell file |
| 478 | generated with the "-ascii" argument will not contain the table with |
| 479 | characters, so that it can be combine with spell files for any encoding. |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 480 | |
Bram Moolenaar | e756604 | 2005-06-17 22:00:15 +0000 | [diff] [blame] | 481 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 482 | AFFIXES |
| 483 | *spell-affix-PFX* *spell-affix-SFX* |
| 484 | The usual PFX (prefix) and SFX (suffix) lines are supported (see the Myspell |
| 485 | documentation). Note that Myspell ignores any extra text after the relevant |
| 486 | info. Vim requires this text to start with a "#" so that mistakes don't go |
| 487 | unnoticed. Example: |
| 488 | |
| 489 | SFX F 0 in [^i]n # Spion > Spionin ~ |
| 490 | |
| 491 | *spell-affix-PFXPOSTPONE* |
| 492 | When an affix file has very many prefixes that apply to many words it's not |
| 493 | possible to build the whole word list in memory. This applies to Hebrew (a |
| 494 | list with all words is over a Gbyte). In that case applying prefixes must be |
| 495 | postponed. This makes spell checking slower. It is indicated by this keyword |
| 496 | in the .aff file: |
| 497 | |
| 498 | PFXPOSTPONE ~ |
| 499 | |
| 500 | Only prefixes without a chop string can be postponed, prefixes with a chop |
| 501 | string will still be included in the word list. |
| 502 | |
| 503 | |
| 504 | KEEP-CASE WORDS |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 505 | *spell-affix-KEP* |
| 506 | In the affix file a KEP line can be used to define the affix name used for |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 507 | keep-case words. Example: |
| 508 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 509 | KEP = ~ |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 510 | |
| 511 | See above for an example |spell-affix-vim|. |
| 512 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 513 | |
| 514 | RARE WORDS |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 515 | *spell-affix-RAR* |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 516 | In the affix file a RAR line can be used to define the affix name used for |
| 517 | rare words. Example: |
| 518 | |
| 519 | RAR ? ~ |
| 520 | |
| 521 | Rare words are highlighted differently from bad words. This is to be used for |
| 522 | words that are correct for the language, but are hardly ever used and could be |
| 523 | a typing mistake anyway. |
| 524 | |
| 525 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 526 | REPLACEMENTS *spell-affix-REP* |
| 527 | |
| 528 | In the affix file REP items can be used to define common mistakes. This is |
| 529 | used to make spelling suggestions. The items define the "from" text and the |
| 530 | "to" replacement. Example: |
| 531 | |
| 532 | REP 4 ~ |
| 533 | REP f ph ~ |
| 534 | REP ph f ~ |
| 535 | REP k ch ~ |
| 536 | REP ch k ~ |
| 537 | |
| 538 | The first line specifies the number of REP lines following. Vim ignores it. |
| 539 | |
| 540 | |
| 541 | SIMILAR CHARACTERS *spell-affix-MAP* |
| 542 | |
| 543 | In the affix file MAP items can be used to define letters that very much |
| 544 | alike. This is mostly used for a letter with different accents. This is used |
| 545 | to prefer suggestions with these letters substituted. Example: |
| 546 | |
| 547 | MAP 2 ~ |
| 548 | MAP eéëêè ~ |
| 549 | MAP uüùúû ~ |
| 550 | |
| 551 | The first line specifies the number of MAP lines following. Vim ignores it. |
| 552 | |
Bram Moolenaar | e756604 | 2005-06-17 22:00:15 +0000 | [diff] [blame] | 553 | A letter must only appear in one of the MAP items. It's a bit more efficient |
| 554 | if the first letter is ASCII or at least one without accents. |
| 555 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 556 | |
| 557 | SOUNDS-A-LIKE *spell-affix-SAL* |
| 558 | |
| 559 | In the affix file SAL items can be used to define the sounds-a-like mechanism |
| 560 | to be used. The main items define the "from" text and the "to" replacement. |
| 561 | Example: |
| 562 | |
| 563 | SAL CIA X ~ |
| 564 | SAL CH X ~ |
| 565 | SAL C K ~ |
| 566 | SAL K K ~ |
| 567 | |
| 568 | TODO: explain how it works. |
| 569 | |
| 570 | There are a few special items: |
| 571 | |
| 572 | SAL followup true ~ |
| 573 | SAL collapse_result true ~ |
| 574 | SAL remove_accents true ~ |
| 575 | |
| 576 | "1" has the same meaning as "true". Any other value means "false". |
| 577 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 578 | vim:tw=78:sw=4:ts=8:ft=help:norl: |