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