Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 1 | *spell.txt* For Vim version 7.0aa. Last change: 2005 Jul 01 |
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 | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 10 | 2. Remarks on spell checking |spell-remarks| |
| 11 | 3. Generating a spell file |spell-mkspell| |
| 12 | 4. Spell file format |spell-file-format| |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 13 | |
| 14 | {Vi does not have any of these commands} |
| 15 | |
| 16 | Spell checking is not available when the |+syntax| feature has been disabled |
| 17 | at compile time. |
| 18 | |
| 19 | ============================================================================== |
| 20 | 1. Quick start *spell-quickstart* |
| 21 | |
| 22 | This command switches on spell checking: > |
| 23 | |
| 24 | :setlocal spell spelllang=en_us |
| 25 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 26 | 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] | 27 | |
| 28 | The words that are not recognized are highlighted with one of these: |
Bram Moolenaar | 520470a | 2005-06-16 21:59:56 +0000 | [diff] [blame] | 29 | SpellBad word not recognized |hl-SpellBad| |
| 30 | SpellRare rare word |hl-SpellRare| |
| 31 | SpellLocal wrong spelling for selected region |hl-SpellLocal| |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 32 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 33 | Vim only checks words for spelling, there is no grammar check. |
| 34 | |
| 35 | To search for the next misspelled word: |
| 36 | |
| 37 | *]s* *E756* |
| 38 | ]s Move to next misspelled word after the cursor. |
Bram Moolenaar | 9d0ec2e | 2005-04-20 19:45:58 +0000 | [diff] [blame] | 39 | A count before the command can be used to repeat. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 40 | |
| 41 | *[s* |
Bram Moolenaar | 9d0ec2e | 2005-04-20 19:45:58 +0000 | [diff] [blame] | 42 | [s Like "]s" but search backwards, find the misspelled |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 43 | word before the cursor. Doesn't recognize words |
| 44 | split over two lines, thus may stop at words that are |
| 45 | not highlighted as bad. |
Bram Moolenaar | 9d0ec2e | 2005-04-20 19:45:58 +0000 | [diff] [blame] | 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. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 53 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 54 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 55 | To add words to your own word list: *E764* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 56 | |
| 57 | *zg* |
| 58 | zg Add word under the cursor as a good word to |
| 59 | 'spellfile'. In Visual mode the selected characters |
| 60 | are added as a word (including white space!). |
| 61 | |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 62 | *zG* |
| 63 | zG Like "zg" but add the word to the internal word list. |
| 64 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 65 | *zw* |
| 66 | zw Add word under the cursor as a wrong (bad) word to |
| 67 | 'spellfile'. In Visual mode the selected characters |
| 68 | are added as a word (including white space!). |
| 69 | |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 70 | *zW* |
| 71 | zW Like "zw" but add the word to the internal word list. |
| 72 | |
Bram Moolenaar | 520470a | 2005-06-16 21:59:56 +0000 | [diff] [blame] | 73 | *:spe* *:spellgood* |
| 74 | :spe[llgood] {word} Add [word} as a good word to 'spellfile'. |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 75 | |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 76 | :spe[llgood]! {word} Add [word} as a good word to the internal word list. |
| 77 | |
Bram Moolenaar | 520470a | 2005-06-16 21:59:56 +0000 | [diff] [blame] | 78 | *:spellw* *:spellwrong* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 79 | :spellw[rong] {word} Add [word} as a wrong (bad) word to 'spellfile'. |
| 80 | |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 81 | :spellw[rong]! {word} Add [word} as a wrong (bad) word to the internal word |
| 82 | list. |
| 83 | |
Bram Moolenaar | f461c8e | 2005-06-25 23:04:51 +0000 | [diff] [blame] | 84 | After adding a word to 'spellfile' with the above commands its associated |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 85 | ".spl" file will automatically be updated and reloaded. If you change |
| 86 | 'spellfile' manually you need to use the |:mkspell| command. This sequence of |
| 87 | commands mostly works well: > |
Bram Moolenaar | f461c8e | 2005-06-25 23:04:51 +0000 | [diff] [blame] | 88 | :exe 'e ' . &spellfile |
| 89 | < (make changes to the spell file) > |
| 90 | :mkspell! % |
| 91 | |
| 92 | More details about the 'spellfile' format below |spell-wordlist-format|. |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 93 | |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 94 | The internal word list is used for all buffers where 'spell' is set. It is |
| 95 | not stored, it is lost when you exit Vim. It is also cleared when 'encoding' |
| 96 | is set. |
| 97 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 98 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 99 | Finding suggestions for bad words: |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 100 | *z?* |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 101 | z? For the word under/after the cursor suggest correctly |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 102 | spelled words. This also works to find alternatives |
| 103 | for a word that is not highlighted as a bad word, |
| 104 | e.g., when the word after it is bad. |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 105 | The results are sorted on similarity to the word |
| 106 | under/after the cursor. |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 107 | This may take a long time. Hit CTRL-C when you are |
| 108 | bored. |
Bram Moolenaar | 24bbcfe | 2005-06-28 23:32:02 +0000 | [diff] [blame] | 109 | This does not work when there is a line break halfway |
| 110 | a bad word (e.g., "the the"). |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 111 | You can enter the number of your choice or press |
Bram Moolenaar | 24bbcfe | 2005-06-28 23:32:02 +0000 | [diff] [blame] | 112 | <Enter> if you don't want to replace. You can also |
| 113 | use the mouse to click on your choice (only works if |
| 114 | the mouse can be used in Normal mode and when there |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 115 | are no line wraps). Click on the first (header) line |
Bram Moolenaar | 24bbcfe | 2005-06-28 23:32:02 +0000 | [diff] [blame] | 116 | to cancel. |
Bram Moolenaar | f3bd51a | 2005-06-14 22:11:18 +0000 | [diff] [blame] | 117 | If 'verbose' is non-zero a score will be displayed to |
| 118 | indicate the likeliness to the badly spelled word (the |
| 119 | higher the score the more different). |
Bram Moolenaar | d857f0e | 2005-06-21 22:37:39 +0000 | [diff] [blame] | 120 | When a word was replaced the redo command "." will |
| 121 | repeat the word replacement. This works like "ciw", |
| 122 | the good word and <Esc>. |
| 123 | |
Bram Moolenaar | 24bbcfe | 2005-06-28 23:32:02 +0000 | [diff] [blame] | 124 | *:spellr* *:spellrepall* *E752* *E753* |
| 125 | :spellr[epall] Repeat the replacement done by |z?| for all matches |
| 126 | with the replaced word in the current window. |
| 127 | |
Bram Moolenaar | d857f0e | 2005-06-21 22:37:39 +0000 | [diff] [blame] | 128 | The 'spellsuggest' option influences how the list of suggestions is generated |
| 129 | and sorted. See |'spellsuggest'|. |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 130 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 131 | ============================================================================== |
| 132 | 2. Remarks on spell checking *spell-remarks* |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 133 | |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 134 | PERFORMANCE |
| 135 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 136 | Vim does on-the-fly spell checking. To make this work fast the word list is |
| 137 | loaded in memory. Thus this uses a lot of memory (1 Mbyte or more). There |
| 138 | might also be a noticeable delay when the word list is loaded, which happens |
| 139 | when 'spell' is set and when 'spelllang' is set while 'spell' was already set. |
| 140 | To minimize the delay each word list is only loaded once, it is not deleted |
| 141 | when 'spelllang' is made empty or 'spell' is reset. When 'encoding' is set |
| 142 | all the word lists are reloaded, thus you may notice a delay then too. |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 143 | |
| 144 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 145 | REGIONS |
| 146 | |
| 147 | A word may be spelled differently in various regions. For example, English |
| 148 | comes in (at least) these variants: |
| 149 | |
| 150 | en all regions |
Bram Moolenaar | 5c5474b | 2005-04-19 21:40:26 +0000 | [diff] [blame] | 151 | en_au Australia |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 152 | en_ca Canada |
Bram Moolenaar | 5c5474b | 2005-04-19 21:40:26 +0000 | [diff] [blame] | 153 | en_gb Great Britain |
| 154 | en_nz New Zealand |
| 155 | en_us USA |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 156 | |
| 157 | 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] | 158 | highlighted with SpellLocal |hl-SpellLocal|. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 159 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 160 | Always use lowercase letters for the language and region names. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 161 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 162 | When adding a word with |zg| or another command it's always added for all |
| 163 | regions. You can change that by manually editing the 'spellfile'. See |
| 164 | |spell-wordlist-format|. |
| 165 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 166 | |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 167 | SPELL FILES *spell-load* |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 168 | |
| 169 | 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] | 170 | 'runtimepath'. The name is: LL.EEE.spl, where: |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 171 | LL the language name |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 172 | EEE the value of 'encoding' |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 173 | |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 174 | The value for "LL" comes from 'spelllang', but excludes the region name. |
| 175 | Examples: |
| 176 | 'spelllang' LL ~ |
| 177 | en_us en |
| 178 | en-rare en-rare |
| 179 | medical_ca medical |
| 180 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 181 | Only the first file is loaded, the one that is first in 'runtimepath'. If |
| 182 | this succeeds then additionally files with the name LL.EEE.add.spl are loaded. |
| 183 | All the ones that are found are used. |
| 184 | |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 185 | Additionally, the file related to 'spellfile' is loaded. This is the file |
| 186 | that |zg| and |zw| add good and wrong words to. |
| 187 | |
Bram Moolenaar | 0e21a3f | 2005-04-17 20:28:32 +0000 | [diff] [blame] | 188 | Exceptions: |
| 189 | - Vim uses "latin1" when 'encoding' is "iso-8859-15". The euro sign doesn't |
| 190 | matter for spelling. |
| 191 | - When no spell file for 'encoding' is found "ascii" is tried. This only |
| 192 | works for languages where nearly all words are ASCII, such as English. It |
| 193 | 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] | 194 | is being edited. For the ".add" files the same name as the found main |
| 195 | spell file is used. |
| 196 | |
| 197 | For example, with these values: |
| 198 | 'runtimepath' is "~/.vim,/usr/share/vim70,~/.vim/after" |
| 199 | 'encoding' is "iso-8859-2" |
| 200 | 'spelllang' is "pl" |
| 201 | |
| 202 | Vim will look for: |
| 203 | 1. ~/.vim/spell/pl.iso-8859-2.spl |
| 204 | 2. /usr/share/vim70/spell/pl.iso-8859-2.spl |
| 205 | 3. ~/.vim/spell/pl.iso-8859-2.add.spl |
| 206 | 4. /usr/share/vim70/spell/pl.iso-8859-2.add.spl |
| 207 | 5. ~/.vim/after/spell/pl.iso-8859-2.add.spl |
| 208 | |
| 209 | This assumes 1. is not found and 2. is found. |
| 210 | |
| 211 | If 'encoding' is "latin1" Vim will look for: |
| 212 | 1. ~/.vim/spell/pl.latin1.spl |
| 213 | 2. /usr/share/vim70/spell/pl.latin1.spl |
| 214 | 3. ~/.vim/after/spell/pl.latin1.spl |
| 215 | 4. ~/.vim/spell/pl.ascii.spl |
| 216 | 5. /usr/share/vim70/spell/pl.ascii.spl |
| 217 | 6. ~/.vim/after/spell/pl.ascii.spl |
| 218 | |
| 219 | This assumes none of them are found (Polish doesn't make sense when leaving |
| 220 | out the non-ASCII characters). |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 221 | |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 222 | Spelling for EBCDIC is currently not supported. |
| 223 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 224 | A spell file might not be available in the current 'encoding'. See |
| 225 | |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] | 226 | with "iconv" will NOT work! |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 227 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 228 | *E758* *E759* |
| 229 | 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] | 230 | get an error the file may be truncated, modified or intended for another Vim |
| 231 | version. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 232 | |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 233 | |
| 234 | WORDS |
| 235 | |
| 236 | Vim uses a fixed method to recognize a word. This is independent of |
| 237 | 'iskeyword', so that it also works in help files and for languages that |
| 238 | include characters like '-' in 'iskeyword'. The word characters do depend on |
| 239 | 'encoding'. |
| 240 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 241 | The table with word characters is stored in the main .spl file. Therefore it |
| 242 | matters what the current locale is when generating it! A .add.spl file does |
Bram Moolenaar | f461c8e | 2005-06-25 23:04:51 +0000 | [diff] [blame] | 243 | not contain a word table though. |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 244 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 245 | A word that starts with a digit is always ignored. That includes hex numbers |
| 246 | in the form 0xff and 0XFF. |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 247 | |
| 248 | |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 249 | WORD COMBINATIONS |
| 250 | |
| 251 | It is possible to spell-check words that include a space. This is used to |
| 252 | recognize words that are invalid when used by themselves, e.g. for "et al.". |
| 253 | It can also be used to recognize "the the" and highlight it. |
| 254 | |
| 255 | The number of spaces is irrelevant. In most cases a line break may also |
| 256 | appear. However, this makes it difficult to find out where to start checking |
| 257 | for spelling mistakes. When you make a change to one line and only that line |
| 258 | is redrawn Vim won't look in the previous line, thus when "et" is at the end |
| 259 | of the previous line "al." will be flagged as an error. And when you type |
| 260 | "the<CR>the" the highlighting doesn't appear until the first line is redrawn. |
| 261 | Use |CTRL-L| to redraw right away. "[s" will also stop at a word combination |
| 262 | with a line break. |
| 263 | |
| 264 | When encountering a line break Vim skips characters such as '*', '>' and '"', |
| 265 | so that comments in C, shell and Vim code can be spell checked. |
| 266 | |
| 267 | |
Bram Moolenaar | 9d0ec2e | 2005-04-20 19:45:58 +0000 | [diff] [blame] | 268 | SYNTAX HIGHLIGHTING *spell-syntax* |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 269 | |
| 270 | Files that use syntax highlighting can specify where spell checking should be |
| 271 | done: |
| 272 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 273 | 1. everywhere default |
| 274 | 2. in specific items use "contains=@Spell" |
| 275 | 3. everywhere but specific items use "contains=@NoSpell" |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 276 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 277 | For the second method adding the @NoSpell cluster will disable spell checking |
| 278 | again. This can be used, for example, to add @Spell to the comments of a |
| 279 | program, and add @NoSpell for items that shouldn't be checked. |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 280 | |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 281 | |
| 282 | VIM SCRIPTS |
| 283 | |
| 284 | If you want to write a Vim script that does something with spelling, you may |
| 285 | find these functions useful: |
| 286 | |
| 287 | spellbadword() find badly spelled word at the cursor |
| 288 | spellsuggest() get list of spelling suggestions |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 289 | soundfold() get the sound-a-like version of a word |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 290 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 291 | ============================================================================== |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 292 | 3. Generating a spell file *spell-mkspell* |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 293 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 294 | Vim uses a binary file format for spelling. This greatly speeds up loading |
| 295 | the word list and keeps it small. |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 296 | *.aff* *.dic* *Myspell* |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 297 | You can create a Vim spell file from the .aff and .dic files that Myspell |
| 298 | uses. Myspell is used by OpenOffice.org and Mozilla. You should be able to |
| 299 | find them here: |
| 300 | http://lingucomponent.openoffice.org/spell_dic.html |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 301 | You can also use a plain word list. The results are the same, the choice |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 302 | depends on what word lists you can find. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 303 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 304 | Make sure your current locale is set properly, otherwise Vim doesn't know what |
| 305 | characters are upper/lower case letters. If the locale isn't available (e.g., |
| 306 | when using an MS-Windows codepage on Unix) add tables to the .aff file |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 307 | |spell-affix-chars|. If the .aff file doesn't define a table then the word |
| 308 | table of the currently active spelling is used. If spelling is not active |
| 309 | then Vim will try to guess. |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 310 | |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 311 | *:mksp* *:mkspell* |
| 312 | :mksp[ell][!] [-ascii] {outname} {inname} ... |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 313 | Generate a Vim spell file word lists. Example: > |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 314 | :mkspell /tmp/nl nl_NL.words |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 315 | < *E751* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 316 | When {outname} ends in ".spl" it is used as the output |
| 317 | file name. Otherwise it should be a language name, |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 318 | such as "en", without the region name. The file |
| 319 | written will be "{outname}.{encoding}.spl", where |
| 320 | {encoding} is the value of the 'encoding' option. |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 321 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 322 | When the output file already exists [!] must be used |
Bram Moolenaar | 520470a | 2005-06-16 21:59:56 +0000 | [diff] [blame] | 323 | to overwrite it. |
| 324 | |
Bram Moolenaar | 0e21a3f | 2005-04-17 20:28:32 +0000 | [diff] [blame] | 325 | When the [-ascii] argument is present, words with |
| 326 | non-ascii characters are skipped. The resulting file |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 327 | ends in "ascii.spl". |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 328 | |
| 329 | The input can be the Myspell format files {inname}.aff |
| 330 | and {inname}.dic. If {inname}.aff does not exist then |
| 331 | {inname} is used as the file name of a plain word |
| 332 | list. |
| 333 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 334 | Multiple {inname} arguments can be given to combine |
| 335 | regions into one Vim spell file. Example: > |
| 336 | :mkspell ~/.vim/spell/en /tmp/en_US /tmp/en_CA /tmp/en_AU |
| 337 | < This combines the English word lists for US, CA and AU |
| 338 | into one en.spl file. |
| 339 | Up to eight regions can be combined. *E754* *755* |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 340 | The REP and SAL items of the first .aff file where |
| 341 | they appear are used. |spell-affix-REP| |
| 342 | |spell-affix-SAL| |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 343 | |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 344 | This command uses a lot of memory, required to find |
| 345 | the optimal word tree (Polish requires a few hundred |
| 346 | Mbyte). The final result will be much smaller. |
| 347 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 348 | After the spell file was written and it was being used |
| 349 | in a buffer it will be reloaded automatically. |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 350 | |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 351 | :mksp[ell] [-ascii] {name}.{enc}.add |
| 352 | Like ":mkspell" above, using {name}.{enc}.add as the |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 353 | input file and producing an output file in the same |
| 354 | directory that has ".spl" appended. |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 355 | |
| 356 | :mksp[ell] [-ascii] {name} |
| 357 | Like ":mkspell" above, using {name} as the input file |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 358 | and producing an output file in the same directory |
| 359 | that has ".{enc}.spl" appended. |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 360 | |
| 361 | Since you might want to change a Myspell word list for use with Vim the |
| 362 | following procedure is recommended: |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 363 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 364 | 1. Obtain the xx_YY.aff and xx_YY.dic files from Myspell. |
| 365 | 2. Make a copy of these files to xx_YY.orig.aff and xx_YY.orig.dic. |
| 366 | 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] | 367 | words, define word characters with FOL/LOW/UPP, etc. The distributed |
| 368 | "src/spell/*.diff" files can be used. |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 369 | 4. Start Vim with the right locale and use |:mkspell| to generate the Vim |
| 370 | spell file. |
| 371 | 5. Try out the spell file with ":set spell spelllang=xx" if you wrote it in |
| 372 | a spell directory in 'runtimepath, or ":set spelllang=xx.enc.spl" if you |
| 373 | wrote it somewhere else. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 374 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 375 | When the Myspell files are updated you can merge the differences: |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 376 | 1. Obtain the new Myspell files as xx_YY.new.aff and xx_UU.new.dic. |
| 377 | 2. Use Vimdiff to see what changed: > |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 378 | vimdiff xx_YY.orig.dic xx_YY.new.dic |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 379 | 3. Take over the changes you like in xx_YY.dic. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 380 | You may also need to change xx_YY.aff. |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 381 | 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] | 382 | |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 383 | |
| 384 | SPELL FILE DUMP |
| 385 | |
| 386 | If for some reason you want to check what words are supported by the currently |
| 387 | used spelling files, use this command: |
| 388 | |
| 389 | *:spelldump* *:spelld* |
| 390 | :spelld[ump] Open a new window and fill it with all currently valid |
| 391 | words. |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 392 | Note: For some languages the result may be enormous, |
| 393 | causing Vim to run out of memory. |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 394 | |
| 395 | The format of the word list is used |spell-wordlist-format|. You should be |
| 396 | able to read it with ":mkspell" to generate one .spl file that includes all |
| 397 | the words. |
| 398 | |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 399 | When all entries to 'spelllang' use the same regions or no regions at all then |
| 400 | the region information is included in the dumped words. Otherwise only words |
| 401 | for the current region are included and no "/regions" line is generated. |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 402 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 403 | Comment lines with the name of the .spl file are used as a header above the |
| 404 | words that were generated from that .spl file. |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 405 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 406 | ============================================================================== |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 407 | 4. Spell file format *spell-file-format* |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 408 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 409 | This is the format of the files that are used by the person who creates and |
| 410 | maintains a word list. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 411 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 412 | Note that we avoid the word "dictionary" here. That is because the goal of |
| 413 | spell checking differs from writing a dictionary (as in the book). For |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 414 | spelling we need a list of words that are OK, thus should not to be |
| 415 | highlighted. Person and company names will not appear in a dictionary, but do |
| 416 | appear in a word list. And some old words are rarely used while they are |
| 417 | common misspellings. These do appear in a dictionary but not in a word list. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 418 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 419 | There are two formats: A straigth list of words and a list using affix |
| 420 | compression. The files with affix compression are used by Myspell (Mozilla |
| 421 | and OpenOffice.org). This requires two files, one with .aff and one with .dic |
| 422 | extension. |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 423 | |
| 424 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 425 | FORMAT OF STRAIGHT WORD LIST *spell-wordlist-format* |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 426 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 427 | The words must appear one per line. That is all that is required. |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 428 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 429 | Additionally the following items are recognized: |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 430 | |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 431 | - Empty and blank lines are ignored. |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 432 | |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 433 | - Lines starting with a # are ignored (comment lines). |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 434 | |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 435 | - A line starting with "/encoding=", before any word, specifies the encoding |
| 436 | of the file. After the second '=' comes an encoding name. This tells Vim |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 437 | to setup conversion from the specified encoding to 'encoding'. Thus you can |
| 438 | use one word list for several target encodings. |
| 439 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 440 | - A line starting with "/regions=" specifies the region names that are |
| 441 | supported. Each region name must be two ASCII letters. The first one is |
| 442 | region 1. Thus "/regions=usca" has region 1 "us" and region 2 "ca". |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 443 | In an addition word list the region names should be equal to the main word |
| 444 | list! |
| 445 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 446 | - Other lines starting with '/' are reserved for future use. The ones that |
| 447 | are not recognized are ignored (but you do get a warning message). |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 448 | |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 449 | - A "/" may follow the word with the following items: |
| 450 | = Case must match exactly. |
| 451 | ? Rare word. |
| 452 | ! Bad (wrong) word. |
| 453 | digit A region in which the word is valid. If no regions are |
| 454 | specified the word is valid in all regions. |
| 455 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 456 | Example: |
| 457 | |
| 458 | # This is an example word list comment |
| 459 | /encoding=latin1 encoding of the file |
| 460 | /regions=uscagb regions "us", "ca" and "gb" |
| 461 | example word for all regions |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 462 | blah/12 word for regions "us" and "ca" |
| 463 | vim/! bad word |
| 464 | Campbell/?3 rare word in region 3 "gb" |
| 465 | 's mornings/= keep-case word |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 466 | |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 467 | |
| 468 | FORMAT WITH AFFIX COMPRESSION |
| 469 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 470 | There are two files: the basic word list and an affix file. The affixes are |
| 471 | used to modify the basic words to get the full word list. This significantly |
| 472 | reduces the number of words, especially for a language like Polish. This is |
| 473 | called affix compression. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 474 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 475 | The format for the affix and word list files is mostly identical to what |
| 476 | Myspell uses (the spell checker of Mozilla and OpenOffice.org). A description |
| 477 | can be found here: |
| 478 | http://lingucomponent.openoffice.org/affix.readme ~ |
| 479 | 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] | 480 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 481 | Vim supports a few extras. Hopefully Myspell will support these too some day. |
| 482 | See |spell-affix-vim|. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 483 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 484 | The basic word list and the affix file are combined and turned into a binary |
| 485 | spell file. All the preprocessing has been done, thus this file loads fast. |
| 486 | The binary spell file format is described in the source code (src/spell.c). |
| 487 | But only developers need to know about it. |
| 488 | |
| 489 | The preprocessing also allows us to take the Myspell language files and modify |
| 490 | them before the Vim word list is made. The tools for this can be found in the |
| 491 | "src/spell" directory. |
| 492 | |
| 493 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 494 | WORD LIST FORMAT *spell-dic-format* |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 495 | |
| 496 | A very short example, with line numbers: |
| 497 | |
| 498 | 1 1234 |
| 499 | 2 aan |
| 500 | 3 Als |
| 501 | 4 Etten-Leur |
| 502 | 5 et al. |
| 503 | 6 's-Gravenhage |
| 504 | 7 's-Gravenhaags |
| 505 | 8 bedel/P |
| 506 | 9 kado/1 |
| 507 | 10 cadeau/2 |
| 508 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 509 | The first line contains the number of words. Vim ignores it, but you do get |
| 510 | an error message if it's not there. *E760* |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 511 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 512 | What follows is one word per line. There should be no white space before or |
| 513 | after the word. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 514 | |
| 515 | When the word only has lower-case letters it will also match with the word |
| 516 | starting with an upper-case letter. |
| 517 | |
| 518 | When the word includes an upper-case letter, this means the upper-case letter |
| 519 | is required at this position. The same word with a lower-case letter at this |
| 520 | position will not match. When some of the other letters are upper-case it will |
| 521 | not match either. |
| 522 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 523 | The word with all upper-case characters will always be OK. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 524 | |
| 525 | word list matches does not match ~ |
| 526 | als als Als ALS ALs AlS aLs aLS |
| 527 | Als Als ALS als ALs AlS aLs aLS |
| 528 | ALS ALS als Als ALs AlS aLs aLS |
| 529 | AlS AlS ALS als Als ALs aLs aLS |
| 530 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 531 | 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] | 532 | only, see below |spell-affix-KEP|. |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 533 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 534 | Note in line 5 to 7 that non-word characters are used. You can include |
| 535 | any character in a word. When checking the text a word still only matches |
| 536 | when it appears with a non-word character before and after it. For Myspell a |
| 537 | word starting with a non-word character probably won't work. |
| 538 | |
| 539 | After the word there is an optional slash and flags. Most of these flags are |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 540 | letters that indicate the affixes that can be used with this word. These are |
| 541 | specified with SFX and PFX lines in the .aff file. See the Myspell |
| 542 | documentation. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 543 | |
| 544 | *spell-affix-vim* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 545 | 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] | 546 | affix file. This has the meaning that case matters. This can be used if the |
| 547 | 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] | 548 | Example (assuming that = was used for KEP): |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 549 | |
| 550 | word list matches does not match ~ |
| 551 | 's morgens/= 's morgens 'S morgens 's Morgens |
| 552 | 's Morgens 's Morgens 'S morgens 's morgens |
| 553 | |
| 554 | *spell-affix-mbyte* |
| 555 | The basic word list is normally in an 8-bit encoding, which is mentioned in |
| 556 | the affix file. The affix file must always be in the same encoding as the |
| 557 | word list. This is compatible with Myspell. For Vim the encoding may also be |
| 558 | something else, any encoding that "iconv" supports. The "SET" line must |
| 559 | specify the name of the encoding. When using a multi-byte encoding it's |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 560 | possible to use more different affixes (but Myspell doesn't support that, thus |
| 561 | you may not want to use it anyway). |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 562 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 563 | |
| 564 | CHARACTER TABLES |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 565 | *spell-affix-chars* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 566 | When using an 8-bit encoding the affix file should define what characters are |
| 567 | word characters (as specified with ENC). This is because the system where |
| 568 | ":mkspell" is used may not support a locale with this encoding and isalpha() |
| 569 | won't work. For example when using "cp1250" on Unix. |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 570 | |
Bram Moolenaar | e756604 | 2005-06-17 22:00:15 +0000 | [diff] [blame] | 571 | *E761* *E762* *spell-affix-FOL* |
| 572 | *spell-affix-LOW* *spell-affix-UPP* |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 573 | Three lines in the affix file are needed. Simplistic example: |
| 574 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 575 | FOL áëñ ~ |
| 576 | LOW áëñ ~ |
| 577 | UPP ÁËÑ ~ |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 578 | |
| 579 | All three lines must have exactly the same number of characters. |
| 580 | |
| 581 | The "FOL" line specifies the case-folded characters. These are used to |
| 582 | compare words while ignoring case. For most encodings this is identical to |
| 583 | the lower case line. |
| 584 | |
| 585 | The "LOW" line specifies the characters in lower-case. Mostly it's equal to |
| 586 | the "FOL" line. |
| 587 | |
| 588 | The "UPP" line specifies the characters with upper-case. That is, a character |
| 589 | is upper-case where it's different from the character at the same position in |
| 590 | "FOL". |
| 591 | |
| 592 | ASCII characters should be omitted, Vim always handles these in the same way. |
| 593 | When the encoding is UTF-8 no word characters need to be specified. |
| 594 | |
| 595 | *E763* |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 596 | Vim allows you to use spell checking for several languages in the same file. |
| 597 | You can list them in the 'spelllang' option. As a consequence all spell files |
| 598 | for the same encoding must use the same word characters, otherwise they can't |
| 599 | be combined without errors. If you get a warning that the word tables differ |
| 600 | you may need to generate the .spl file again with |:mkspell|. Check the FOL, |
| 601 | LOW and UPP lines in the used .aff file. |
| 602 | |
| 603 | The XX.ascii.spl spell file generated with the "-ascii" argument will not |
| 604 | contain the table with characters, so that it can be combine with spell files |
| 605 | for any encoding. The .add.spl files also do not contain the table. |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 606 | |
Bram Moolenaar | e756604 | 2005-06-17 22:00:15 +0000 | [diff] [blame] | 607 | |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 608 | MID-WORD CHARACTERS |
| 609 | *spell-midword* |
| 610 | Some characters are only to be considered word characters if they are used in |
| 611 | between two ordinary word characters. An example is the single quote: It is |
| 612 | often used to put text in quotes, thus it can't be recognized as a word |
| 613 | character, but when it appears in between word characters it must be part of |
| 614 | the word. This is needed to detect a spelling error such as they'are. That |
| 615 | should be they're, but since "they" and "are" are words themselves that would |
| 616 | go unnoticed. |
| 617 | |
| 618 | These characters are defined with MIDWORD in the .aff file: |
| 619 | |
| 620 | MIDWORD '- ~ |
| 621 | |
| 622 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 623 | AFFIXES |
| 624 | *spell-affix-PFX* *spell-affix-SFX* |
| 625 | The usual PFX (prefix) and SFX (suffix) lines are supported (see the Myspell |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 626 | documentation or the Aspell manual: |
| 627 | http://aspell.net/man-html/Affix-Compression.html). |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 628 | |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 629 | Note that Myspell ignores any extra text after the relevant info. Vim |
| 630 | requires this text to start with a "#" so that mistakes don't go unnoticed. |
| 631 | Example: |
| 632 | |
| 633 | SFX F 0 in [^i]n # Spion > Spionin ~ |
| 634 | SFX F 0 nen in # Bauerin > Bauerinnen ~ |
| 635 | |
| 636 | An extra item for Vim is the "rare" flag. It must come after the other |
| 637 | fields, before a comment. When used then all words that use the affix will be |
| 638 | marked as rare words. Example: |
| 639 | |
| 640 | PFX F 0 nene . rare ~ |
| 641 | SFX F 0 oin n rare # hardly ever used ~ |
| 642 | |
| 643 | However, if the word also appears as a good word in another way it won't be |
| 644 | marked as rare. |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 645 | |
| 646 | *spell-affix-PFXPOSTPONE* |
| 647 | When an affix file has very many prefixes that apply to many words it's not |
| 648 | possible to build the whole word list in memory. This applies to Hebrew (a |
| 649 | list with all words is over a Gbyte). In that case applying prefixes must be |
| 650 | postponed. This makes spell checking slower. It is indicated by this keyword |
| 651 | in the .aff file: |
| 652 | |
| 653 | PFXPOSTPONE ~ |
| 654 | |
| 655 | Only prefixes without a chop string can be postponed, prefixes with a chop |
| 656 | string will still be included in the word list. |
| 657 | |
| 658 | |
| 659 | KEEP-CASE WORDS |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 660 | *spell-affix-KEP* |
| 661 | 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] | 662 | keep-case words. Example: |
| 663 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 664 | KEP = ~ |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 665 | |
| 666 | See above for an example |spell-affix-vim|. |
| 667 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 668 | |
| 669 | RARE WORDS |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 670 | *spell-affix-RAR* |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 671 | In the affix file a RAR line can be used to define the affix name used for |
| 672 | rare words. Example: |
| 673 | |
| 674 | RAR ? ~ |
| 675 | |
| 676 | Rare words are highlighted differently from bad words. This is to be used for |
| 677 | words that are correct for the language, but are hardly ever used and could be |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 678 | a typing mistake anyway. When the same word is found as good it won't be |
| 679 | highlighted as rare. |
| 680 | |
| 681 | |
| 682 | BAD WORDS |
| 683 | *spell-affix-BAD* |
| 684 | In the affix file a BAD line can be used to define the affix name used for |
| 685 | bad words. Example: |
| 686 | |
| 687 | BAD ! ~ |
| 688 | |
| 689 | This can be used to exclude words that would otherwise be good. For example |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 690 | "the the" in the .dic file: |
| 691 | |
| 692 | the the/! ~ |
| 693 | |
| 694 | Once a word has been marked as bad it won't be undone by encountering the same |
| 695 | word as good. |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 696 | |
| 697 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 698 | REPLACEMENTS *spell-affix-REP* |
| 699 | |
| 700 | In the affix file REP items can be used to define common mistakes. This is |
| 701 | used to make spelling suggestions. The items define the "from" text and the |
| 702 | "to" replacement. Example: |
| 703 | |
| 704 | REP 4 ~ |
| 705 | REP f ph ~ |
| 706 | REP ph f ~ |
| 707 | REP k ch ~ |
| 708 | REP ch k ~ |
| 709 | |
| 710 | The first line specifies the number of REP lines following. Vim ignores it. |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 711 | Don't include simple one-character replacements or swaps. Vim will try these |
| 712 | anyway. You can include whole words if you want to, but you might want to use |
| 713 | the "file:" item in 'spellsuggest' instead. |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 714 | |
| 715 | |
| 716 | SIMILAR CHARACTERS *spell-affix-MAP* |
| 717 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 718 | In the affix file MAP items can be used to define letters that are very much |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 719 | alike. This is mostly used for a letter with different accents. This is used |
| 720 | to prefer suggestions with these letters substituted. Example: |
| 721 | |
| 722 | MAP 2 ~ |
| 723 | MAP eéëêè ~ |
| 724 | MAP uüùúû ~ |
| 725 | |
| 726 | The first line specifies the number of MAP lines following. Vim ignores it. |
| 727 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 728 | Each letter must appear in only one of the MAP items. It's a bit more |
| 729 | efficient if the first letter is ASCII or at least one without accents. |
Bram Moolenaar | e756604 | 2005-06-17 22:00:15 +0000 | [diff] [blame] | 730 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 731 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 732 | SOUND-A-LIKE *spell-affix-SAL* |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 733 | |
| 734 | In the affix file SAL items can be used to define the sounds-a-like mechanism |
| 735 | to be used. The main items define the "from" text and the "to" replacement. |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 736 | Simplistic example: |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 737 | |
| 738 | SAL CIA X ~ |
| 739 | SAL CH X ~ |
| 740 | SAL C K ~ |
| 741 | SAL K K ~ |
| 742 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 743 | There are a few rules and this can become quite complicated. An explantion |
| 744 | how it works can be found in the Aspell manual: |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 745 | http://aspell.net/man-html/Phonetic-Code.html. |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 746 | |
| 747 | There are a few special items: |
| 748 | |
| 749 | SAL followup true ~ |
| 750 | SAL collapse_result true ~ |
| 751 | SAL remove_accents true ~ |
| 752 | |
| 753 | "1" has the same meaning as "true". Any other value means "false". |
| 754 | |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 755 | |
| 756 | SIMPLE SOUNDFOLDING *spell-affix-SOFOFROM* *spell-affix-SOFOTO* |
| 757 | |
| 758 | The SAL mechanism is complex and slow. A simpler mechanism is mapping all |
| 759 | characters to another character, mapping similar sounding characters to the |
| 760 | same character. At the same time this does case folding. You can not have |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 761 | both SAL items and simple soundfolding. |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 762 | |
| 763 | There are two items required: one to speficy the characters that are mapped |
| 764 | and one that specifies the characters they are mapped to. They must have |
| 765 | exactly the same number of characters. Example: |
| 766 | |
| 767 | SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~ |
| 768 | SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkes ~ |
| 769 | |
| 770 | In the example all vowels are mapped to the same character 'e'. Another |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 771 | method would be to leave out all vowels. Some characters that sound nearly |
| 772 | the same and are often mixed up, such as 'm' and 'n', are mapped to the same |
| 773 | character. Don't do this too much, all words will start looking alike. |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 774 | |
| 775 | Characters that do not appear in SOFOFROM will be left out, except that all |
| 776 | white space is replaced by one space. Sequences of the same character in |
| 777 | SOFOFROM are replaced by one. |
| 778 | |
| 779 | You can use the |soundfold()| function to try out the results. Or set the |
| 780 | 'verbose' option to see the score in the output of the |z?| command. |
| 781 | |
| 782 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 783 | vim:tw=78:sw=4:ts=8:ft=help:norl: |