Bram Moolenaar | ae5bce1 | 2005-08-15 21:41:48 +0000 | [diff] [blame^] | 1 | *spell.txt* For Vim version 7.0aa. Last change: 2005 Aug 15 |
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| |
Bram Moolenaar | 7d1f5db | 2005-07-03 21:39:27 +0000 | [diff] [blame] | 30 | SpellCap word not capitalised |hl-SpellCap| |
Bram Moolenaar | 520470a | 2005-06-16 21:59:56 +0000 | [diff] [blame] | 31 | SpellRare rare word |hl-SpellRare| |
| 32 | SpellLocal wrong spelling for selected region |hl-SpellLocal| |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 33 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 34 | Vim only checks words for spelling, there is no grammar check. |
| 35 | |
Bram Moolenaar | 4536002 | 2005-07-21 21:08:21 +0000 | [diff] [blame] | 36 | If the 'mousemodel' option is set to "popup" and the cursor is on a badly |
| 37 | spelled word or it is "popup_setpos" and the mouse pointer is on a badly |
| 38 | spelled word, then the popup menu will contain an submenu to replace the bad |
| 39 | word. Note: this slows down the appearance of the popup menu. |
| 40 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 41 | To search for the next misspelled word: |
| 42 | |
| 43 | *]s* *E756* |
| 44 | ]s Move to next misspelled word after the cursor. |
Bram Moolenaar | 9d0ec2e | 2005-04-20 19:45:58 +0000 | [diff] [blame] | 45 | A count before the command can be used to repeat. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 46 | |
| 47 | *[s* |
Bram Moolenaar | 9d0ec2e | 2005-04-20 19:45:58 +0000 | [diff] [blame] | 48 | [s Like "]s" but search backwards, find the misspelled |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 49 | word before the cursor. Doesn't recognize words |
| 50 | split over two lines, thus may stop at words that are |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 51 | not highlighted as bad. Does not stop at word with |
| 52 | missing capital at the start of a line. |
Bram Moolenaar | 9d0ec2e | 2005-04-20 19:45:58 +0000 | [diff] [blame] | 53 | |
| 54 | *]S* |
| 55 | ]S Like "]s" but only stop at bad words, not at rare |
| 56 | words or words for another region. |
| 57 | |
| 58 | *[S* |
| 59 | [S Like "]S" but search backwards. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 60 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 61 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 62 | To add words to your own word list: *E764* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 63 | |
| 64 | *zg* |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 65 | zg Add word under the cursor as a good word to the first |
| 66 | name in 'spellfile'. In Visual mode the selected |
| 67 | characters are added as a word (including white |
| 68 | space!). If the word is explicitly marked as bad word |
| 69 | in another spell file the result is unpredictable. |
| 70 | A count may precede the command to indicate the entry |
| 71 | in 'spellfile' to be used. A count of two uses the |
| 72 | second entry. |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 73 | |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 74 | *zG* |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 75 | zG Like "zg" but add the word to the internal word list |
| 76 | |internal-wordlist|. |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 77 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 78 | *zw* |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 79 | zw Like "zg" but mark the word as a wrong (bad) word. |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 80 | |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 81 | *zW* |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 82 | zW Like "zw" but add the word to the internal word list |
| 83 | |internal-wordlist|. |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 84 | |
Bram Moolenaar | 520470a | 2005-06-16 21:59:56 +0000 | [diff] [blame] | 85 | *:spe* *:spellgood* |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 86 | :[count]spe[llgood] {word} |
Bram Moolenaar | 53180ce | 2005-07-05 21:48:14 +0000 | [diff] [blame] | 87 | Add {word} as a good word to 'spellfile', like with |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 88 | "zg". Without count the first name is used, with a |
| 89 | count of two the second entry, etc. |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 90 | |
Bram Moolenaar | 53180ce | 2005-07-05 21:48:14 +0000 | [diff] [blame] | 91 | :spe[llgood]! {word} Add {word} as a good word to the internal word list, |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 92 | like with "zG". |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 93 | |
Bram Moolenaar | 520470a | 2005-06-16 21:59:56 +0000 | [diff] [blame] | 94 | *:spellw* *:spellwrong* |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 95 | :[count]spellw[rong] {word} |
Bram Moolenaar | 53180ce | 2005-07-05 21:48:14 +0000 | [diff] [blame] | 96 | Add {word} as a wrong (bad) word to 'spellfile', as |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 97 | with "zw". Without count the first name is used, with |
| 98 | a count of two the second entry, etc. |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 99 | |
Bram Moolenaar | 53180ce | 2005-07-05 21:48:14 +0000 | [diff] [blame] | 100 | :spellw[rong]! {word} Add {word} as a wrong (bad) word to the internal word |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 101 | list. |
| 102 | |
Bram Moolenaar | f461c8e | 2005-06-25 23:04:51 +0000 | [diff] [blame] | 103 | After adding a word to 'spellfile' with the above commands its associated |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 104 | ".spl" file will automatically be updated and reloaded. If you change |
| 105 | 'spellfile' manually you need to use the |:mkspell| command. This sequence of |
| 106 | commands mostly works well: > |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 107 | :edit <file in 'spellfile'> |
Bram Moolenaar | f461c8e | 2005-06-25 23:04:51 +0000 | [diff] [blame] | 108 | < (make changes to the spell file) > |
| 109 | :mkspell! % |
| 110 | |
| 111 | More details about the 'spellfile' format below |spell-wordlist-format|. |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 112 | |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 113 | *internal-wordlist* |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 114 | The internal word list is used for all buffers where 'spell' is set. It is |
| 115 | not stored, it is lost when you exit Vim. It is also cleared when 'encoding' |
| 116 | is set. |
| 117 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 118 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 119 | Finding suggestions for bad words: |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 120 | *z?* |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 121 | z? For the word under/after the cursor suggest correctly |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 122 | spelled words. This also works to find alternatives |
| 123 | for a word that is not highlighted as a bad word, |
| 124 | e.g., when the word after it is bad. |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 125 | The results are sorted on similarity to the word |
| 126 | under/after the cursor. |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 127 | This may take a long time. Hit CTRL-C when you are |
| 128 | bored. |
Bram Moolenaar | 24bbcfe | 2005-06-28 23:32:02 +0000 | [diff] [blame] | 129 | This does not work when there is a line break halfway |
| 130 | a bad word (e.g., "the the"). |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 131 | You can enter the number of your choice or press |
Bram Moolenaar | 24bbcfe | 2005-06-28 23:32:02 +0000 | [diff] [blame] | 132 | <Enter> if you don't want to replace. You can also |
| 133 | use the mouse to click on your choice (only works if |
| 134 | the mouse can be used in Normal mode and when there |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 135 | are no line wraps). Click on the first (header) line |
Bram Moolenaar | 24bbcfe | 2005-06-28 23:32:02 +0000 | [diff] [blame] | 136 | to cancel. |
Bram Moolenaar | f3bd51a | 2005-06-14 22:11:18 +0000 | [diff] [blame] | 137 | If 'verbose' is non-zero a score will be displayed to |
| 138 | indicate the likeliness to the badly spelled word (the |
| 139 | higher the score the more different). |
Bram Moolenaar | d857f0e | 2005-06-21 22:37:39 +0000 | [diff] [blame] | 140 | When a word was replaced the redo command "." will |
| 141 | repeat the word replacement. This works like "ciw", |
| 142 | the good word and <Esc>. |
| 143 | |
Bram Moolenaar | 24bbcfe | 2005-06-28 23:32:02 +0000 | [diff] [blame] | 144 | *:spellr* *:spellrepall* *E752* *E753* |
| 145 | :spellr[epall] Repeat the replacement done by |z?| for all matches |
| 146 | with the replaced word in the current window. |
| 147 | |
Bram Moolenaar | 488c651 | 2005-08-11 20:09:58 +0000 | [diff] [blame] | 148 | In Insert mode, when the cursor is after a badly spelled word, you can use |
| 149 | CTRL-X s to find suggestions. This works like Insert mode completion. Use |
| 150 | CTRL-N to use the next suggestion, CTRL-P to go back. |i_CTRL-X_s| |
| 151 | |
Bram Moolenaar | d857f0e | 2005-06-21 22:37:39 +0000 | [diff] [blame] | 152 | The 'spellsuggest' option influences how the list of suggestions is generated |
| 153 | and sorted. See |'spellsuggest'|. |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 154 | |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 155 | The 'spellcapcheck' option is used to check the first word of a sentence |
| 156 | starts with a capital. This doesn't work for the first word in the file. |
| 157 | When there is a line break right after a sentence the highlighting of the next |
Bram Moolenaar | 90cfdbe | 2005-08-12 19:59:19 +0000 | [diff] [blame] | 158 | line may be postponed. Use |CTRL-L| when needed. Also see |set-spc-auto| for |
| 159 | how it can be set automatically when 'spelllang' is set. |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 160 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 161 | ============================================================================== |
| 162 | 2. Remarks on spell checking *spell-remarks* |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 163 | |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 164 | PERFORMANCE |
| 165 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 166 | Vim does on-the-fly spell checking. To make this work fast the word list is |
| 167 | loaded in memory. Thus this uses a lot of memory (1 Mbyte or more). There |
| 168 | might also be a noticeable delay when the word list is loaded, which happens |
| 169 | when 'spell' is set and when 'spelllang' is set while 'spell' was already set. |
| 170 | To minimize the delay each word list is only loaded once, it is not deleted |
| 171 | when 'spelllang' is made empty or 'spell' is reset. When 'encoding' is set |
| 172 | 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] | 173 | |
| 174 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 175 | REGIONS |
| 176 | |
| 177 | A word may be spelled differently in various regions. For example, English |
| 178 | comes in (at least) these variants: |
| 179 | |
| 180 | en all regions |
Bram Moolenaar | 5c5474b | 2005-04-19 21:40:26 +0000 | [diff] [blame] | 181 | en_au Australia |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 182 | en_ca Canada |
Bram Moolenaar | 5c5474b | 2005-04-19 21:40:26 +0000 | [diff] [blame] | 183 | en_gb Great Britain |
| 184 | en_nz New Zealand |
| 185 | en_us USA |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 186 | |
| 187 | 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] | 188 | highlighted with SpellLocal |hl-SpellLocal|. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 189 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 190 | Always use lowercase letters for the language and region names. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 191 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 192 | When adding a word with |zg| or another command it's always added for all |
| 193 | regions. You can change that by manually editing the 'spellfile'. See |
Bram Moolenaar | 0dc065e | 2005-07-04 22:49:24 +0000 | [diff] [blame] | 194 | |spell-wordlist-format|. Note that the regions as specified in the files in |
| 195 | 'spellfile' are only used when all entries in "spelllang" specify the same |
| 196 | region (not counting files specified by their .spl name). |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 197 | |
Bram Moolenaar | ae5bce1 | 2005-08-15 21:41:48 +0000 | [diff] [blame^] | 198 | Specific exception: For German these special regions are used: |
| 199 | de all German words accepted |
| 200 | de_de old and new spelling |
| 201 | de_19 old spelling |
| 202 | de_20 new spelling |
| 203 | de_at Austria |
| 204 | de_ch Switzerland |
| 205 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 206 | |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 207 | SPELL FILES *spell-load* |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 208 | |
| 209 | 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] | 210 | 'runtimepath'. The name is: LL.EEE.spl, where: |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 211 | LL the language name |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 212 | EEE the value of 'encoding' |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 213 | |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 214 | The value for "LL" comes from 'spelllang', but excludes the region name. |
| 215 | Examples: |
| 216 | 'spelllang' LL ~ |
| 217 | en_us en |
| 218 | en-rare en-rare |
| 219 | medical_ca medical |
| 220 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 221 | Only the first file is loaded, the one that is first in 'runtimepath'. If |
| 222 | this succeeds then additionally files with the name LL.EEE.add.spl are loaded. |
| 223 | All the ones that are found are used. |
| 224 | |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 225 | Additionally, the files related to the names in 'spellfile' are loaded. These |
| 226 | are the files that |zg| and |zw| add good and wrong words to. |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 227 | |
Bram Moolenaar | 0e21a3f | 2005-04-17 20:28:32 +0000 | [diff] [blame] | 228 | Exceptions: |
| 229 | - Vim uses "latin1" when 'encoding' is "iso-8859-15". The euro sign doesn't |
| 230 | matter for spelling. |
| 231 | - When no spell file for 'encoding' is found "ascii" is tried. This only |
| 232 | works for languages where nearly all words are ASCII, such as English. It |
| 233 | 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] | 234 | is being edited. For the ".add" files the same name as the found main |
| 235 | spell file is used. |
| 236 | |
| 237 | For example, with these values: |
| 238 | 'runtimepath' is "~/.vim,/usr/share/vim70,~/.vim/after" |
| 239 | 'encoding' is "iso-8859-2" |
| 240 | 'spelllang' is "pl" |
| 241 | |
| 242 | Vim will look for: |
| 243 | 1. ~/.vim/spell/pl.iso-8859-2.spl |
| 244 | 2. /usr/share/vim70/spell/pl.iso-8859-2.spl |
| 245 | 3. ~/.vim/spell/pl.iso-8859-2.add.spl |
| 246 | 4. /usr/share/vim70/spell/pl.iso-8859-2.add.spl |
| 247 | 5. ~/.vim/after/spell/pl.iso-8859-2.add.spl |
| 248 | |
| 249 | This assumes 1. is not found and 2. is found. |
| 250 | |
| 251 | If 'encoding' is "latin1" Vim will look for: |
| 252 | 1. ~/.vim/spell/pl.latin1.spl |
| 253 | 2. /usr/share/vim70/spell/pl.latin1.spl |
| 254 | 3. ~/.vim/after/spell/pl.latin1.spl |
| 255 | 4. ~/.vim/spell/pl.ascii.spl |
| 256 | 5. /usr/share/vim70/spell/pl.ascii.spl |
| 257 | 6. ~/.vim/after/spell/pl.ascii.spl |
| 258 | |
| 259 | This assumes none of them are found (Polish doesn't make sense when leaving |
| 260 | out the non-ASCII characters). |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 261 | |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 262 | Spelling for EBCDIC is currently not supported. |
| 263 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 264 | A spell file might not be available in the current 'encoding'. See |
| 265 | |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] | 266 | with "iconv" will NOT work! |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 267 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 268 | *E758* *E759* |
| 269 | 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] | 270 | get an error the file may be truncated, modified or intended for another Vim |
| 271 | version. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 272 | |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 273 | |
| 274 | WORDS |
| 275 | |
| 276 | Vim uses a fixed method to recognize a word. This is independent of |
| 277 | 'iskeyword', so that it also works in help files and for languages that |
| 278 | include characters like '-' in 'iskeyword'. The word characters do depend on |
| 279 | 'encoding'. |
| 280 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 281 | The table with word characters is stored in the main .spl file. Therefore it |
| 282 | 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] | 283 | not contain a word table though. |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 284 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 285 | A word that starts with a digit is always ignored. That includes hex numbers |
| 286 | in the form 0xff and 0XFF. |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 287 | |
| 288 | |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 289 | WORD COMBINATIONS |
| 290 | |
| 291 | It is possible to spell-check words that include a space. This is used to |
| 292 | recognize words that are invalid when used by themselves, e.g. for "et al.". |
| 293 | It can also be used to recognize "the the" and highlight it. |
| 294 | |
| 295 | The number of spaces is irrelevant. In most cases a line break may also |
| 296 | appear. However, this makes it difficult to find out where to start checking |
| 297 | for spelling mistakes. When you make a change to one line and only that line |
| 298 | is redrawn Vim won't look in the previous line, thus when "et" is at the end |
| 299 | of the previous line "al." will be flagged as an error. And when you type |
| 300 | "the<CR>the" the highlighting doesn't appear until the first line is redrawn. |
| 301 | Use |CTRL-L| to redraw right away. "[s" will also stop at a word combination |
| 302 | with a line break. |
| 303 | |
| 304 | When encountering a line break Vim skips characters such as '*', '>' and '"', |
| 305 | so that comments in C, shell and Vim code can be spell checked. |
| 306 | |
| 307 | |
Bram Moolenaar | 9d0ec2e | 2005-04-20 19:45:58 +0000 | [diff] [blame] | 308 | SYNTAX HIGHLIGHTING *spell-syntax* |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 309 | |
| 310 | Files that use syntax highlighting can specify where spell checking should be |
| 311 | done: |
| 312 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 313 | 1. everywhere default |
| 314 | 2. in specific items use "contains=@Spell" |
| 315 | 3. everywhere but specific items use "contains=@NoSpell" |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 316 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 317 | For the second method adding the @NoSpell cluster will disable spell checking |
| 318 | again. This can be used, for example, to add @Spell to the comments of a |
| 319 | program, and add @NoSpell for items that shouldn't be checked. |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 320 | |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 321 | |
| 322 | VIM SCRIPTS |
| 323 | |
| 324 | If you want to write a Vim script that does something with spelling, you may |
| 325 | find these functions useful: |
| 326 | |
| 327 | spellbadword() find badly spelled word at the cursor |
| 328 | spellsuggest() get list of spelling suggestions |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 329 | soundfold() get the sound-a-like version of a word |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 330 | |
Bram Moolenaar | 90cfdbe | 2005-08-12 19:59:19 +0000 | [diff] [blame] | 331 | |
| 332 | SETTING 'spellcapcheck' AUTOMATICALLY *set-spc-auto* |
| 333 | |
| 334 | After the 'spelllang' option has been set successfully, Vim will source the |
| 335 | files "spell/LANG.vim" in 'runtimepath'. "LANG" is the value of 'spelllang' |
| 336 | up to the first comma, dot or underscore. This can be used to set options |
| 337 | specifically for the language, especially 'spellcapcheck'. |
| 338 | |
| 339 | The distribution includes a few of these files. Use this command to see what |
| 340 | they do: > |
| 341 | :next $VIMRUNTIME/spell/*.vim |
| 342 | |
| 343 | Note that the default scripts don't set 'spellcapcheck' if it was changed from |
| 344 | the default value. This assumes the user prefers another value then. |
| 345 | |
Bram Moolenaar | ae5bce1 | 2005-08-15 21:41:48 +0000 | [diff] [blame^] | 346 | |
| 347 | DOUBLE SCORING *spell-double-scoring* |
| 348 | |
| 349 | The 'spellsuggest' option can be used to select "double" scoring. This |
| 350 | mechanism is based on the principle that there are two kinds of spelling |
| 351 | mistakes: |
| 352 | |
| 353 | 1. You know how to spell the word, but mistype something. This results in a |
| 354 | small editing distance (character swapped/omitted/inserted) and possibly a |
| 355 | word that sounds completely different. |
| 356 | |
| 357 | 2. You don't know how to spell the word and type something that sounds right. |
| 358 | The edit distance can be big but the word is similar after sound-folding. |
| 359 | |
| 360 | Since scores for these two mistakes will be very different we use a list |
| 361 | for each and mix them. |
| 362 | |
| 363 | The sound-folding is slow and people that know the language won't make the |
| 364 | second kind of mistakes. Therefore 'spellsuggest' can be set to select the |
| 365 | preferred method for scoring the suggestions. |
| 366 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 367 | ============================================================================== |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 368 | 3. Generating a spell file *spell-mkspell* |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 369 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 370 | Vim uses a binary file format for spelling. This greatly speeds up loading |
| 371 | the word list and keeps it small. |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 372 | *.aff* *.dic* *Myspell* |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 373 | You can create a Vim spell file from the .aff and .dic files that Myspell |
| 374 | uses. Myspell is used by OpenOffice.org and Mozilla. You should be able to |
| 375 | find them here: |
| 376 | http://lingucomponent.openoffice.org/spell_dic.html |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 377 | 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] | 378 | depends on what word lists you can find. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 379 | |
Bram Moolenaar | 7d1f5db | 2005-07-03 21:39:27 +0000 | [diff] [blame] | 380 | If you install Aap (from www.a-a-p.org) you can use the recipes in the |
| 381 | runtime/spell/??/ directories. Aap will take care of downloading the files, |
| 382 | apply patches needed for Vim and build the .spl file. |
| 383 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 384 | Make sure your current locale is set properly, otherwise Vim doesn't know what |
| 385 | characters are upper/lower case letters. If the locale isn't available (e.g., |
| 386 | 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] | 387 | |spell-affix-chars|. If the .aff file doesn't define a table then the word |
| 388 | table of the currently active spelling is used. If spelling is not active |
| 389 | then Vim will try to guess. |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 390 | |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 391 | *:mksp* *:mkspell* |
| 392 | :mksp[ell][!] [-ascii] {outname} {inname} ... |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 393 | Generate a Vim spell file word lists. Example: > |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 394 | :mkspell /tmp/nl nl_NL.words |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 395 | < *E751* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 396 | When {outname} ends in ".spl" it is used as the output |
| 397 | file name. Otherwise it should be a language name, |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 398 | such as "en", without the region name. The file |
| 399 | written will be "{outname}.{encoding}.spl", where |
| 400 | {encoding} is the value of the 'encoding' option. |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 401 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 402 | When the output file already exists [!] must be used |
Bram Moolenaar | 520470a | 2005-06-16 21:59:56 +0000 | [diff] [blame] | 403 | to overwrite it. |
| 404 | |
Bram Moolenaar | 0e21a3f | 2005-04-17 20:28:32 +0000 | [diff] [blame] | 405 | When the [-ascii] argument is present, words with |
| 406 | non-ascii characters are skipped. The resulting file |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 407 | ends in "ascii.spl". |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 408 | |
| 409 | The input can be the Myspell format files {inname}.aff |
| 410 | and {inname}.dic. If {inname}.aff does not exist then |
| 411 | {inname} is used as the file name of a plain word |
| 412 | list. |
| 413 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 414 | Multiple {inname} arguments can be given to combine |
| 415 | regions into one Vim spell file. Example: > |
| 416 | :mkspell ~/.vim/spell/en /tmp/en_US /tmp/en_CA /tmp/en_AU |
| 417 | < This combines the English word lists for US, CA and AU |
| 418 | into one en.spl file. |
| 419 | Up to eight regions can be combined. *E754* *755* |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 420 | The REP and SAL items of the first .aff file where |
| 421 | they appear are used. |spell-affix-REP| |
| 422 | |spell-affix-SAL| |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 423 | |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 424 | This command uses a lot of memory, required to find |
| 425 | the optimal word tree (Polish requires a few hundred |
| 426 | Mbyte). The final result will be much smaller. |
| 427 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 428 | After the spell file was written and it was being used |
| 429 | in a buffer it will be reloaded automatically. |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 430 | |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 431 | :mksp[ell] [-ascii] {name}.{enc}.add |
| 432 | Like ":mkspell" above, using {name}.{enc}.add as the |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 433 | input file and producing an output file in the same |
| 434 | directory that has ".spl" appended. |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 435 | |
| 436 | :mksp[ell] [-ascii] {name} |
| 437 | Like ":mkspell" above, using {name} as the input file |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 438 | and producing an output file in the same directory |
| 439 | that has ".{enc}.spl" appended. |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 440 | |
Bram Moolenaar | ae5bce1 | 2005-08-15 21:41:48 +0000 | [diff] [blame^] | 441 | Vim will report the number of duplicate words. This might be a mistake in the |
| 442 | list of words. But sometimes it is used to have different prefixes and |
| 443 | suffixes for the same basic word to avoid them combining (e.g. Czech uses |
| 444 | this). |
| 445 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 446 | Since you might want to change a Myspell word list for use with Vim the |
| 447 | following procedure is recommended: |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 448 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 449 | 1. Obtain the xx_YY.aff and xx_YY.dic files from Myspell. |
| 450 | 2. Make a copy of these files to xx_YY.orig.aff and xx_YY.orig.dic. |
| 451 | 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] | 452 | words, define word characters with FOL/LOW/UPP, etc. The distributed |
| 453 | "src/spell/*.diff" files can be used. |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 454 | 4. Start Vim with the right locale and use |:mkspell| to generate the Vim |
| 455 | spell file. |
| 456 | 5. Try out the spell file with ":set spell spelllang=xx" if you wrote it in |
Bram Moolenaar | 7d1f5db | 2005-07-03 21:39:27 +0000 | [diff] [blame] | 457 | a spell directory in 'runtimepath', or ":set spelllang=xx.enc.spl" if you |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 458 | wrote it somewhere else. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 459 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 460 | When the Myspell files are updated you can merge the differences: |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 461 | 1. Obtain the new Myspell files as xx_YY.new.aff and xx_UU.new.dic. |
| 462 | 2. Use Vimdiff to see what changed: > |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 463 | vimdiff xx_YY.orig.dic xx_YY.new.dic |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 464 | 3. Take over the changes you like in xx_YY.dic. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 465 | You may also need to change xx_YY.aff. |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 466 | 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] | 467 | |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 468 | |
| 469 | SPELL FILE DUMP |
| 470 | |
| 471 | If for some reason you want to check what words are supported by the currently |
| 472 | used spelling files, use this command: |
| 473 | |
| 474 | *:spelldump* *:spelld* |
| 475 | :spelld[ump] Open a new window and fill it with all currently valid |
| 476 | words. |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 477 | Note: For some languages the result may be enormous, |
| 478 | causing Vim to run out of memory. |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 479 | |
| 480 | The format of the word list is used |spell-wordlist-format|. You should be |
| 481 | able to read it with ":mkspell" to generate one .spl file that includes all |
| 482 | the words. |
| 483 | |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 484 | When all entries to 'spelllang' use the same regions or no regions at all then |
| 485 | the region information is included in the dumped words. Otherwise only words |
| 486 | for the current region are included and no "/regions" line is generated. |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 487 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 488 | Comment lines with the name of the .spl file are used as a header above the |
| 489 | words that were generated from that .spl file. |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 490 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 491 | ============================================================================== |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 492 | 4. Spell file format *spell-file-format* |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 493 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 494 | This is the format of the files that are used by the person who creates and |
| 495 | maintains a word list. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 496 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 497 | Note that we avoid the word "dictionary" here. That is because the goal of |
| 498 | spell checking differs from writing a dictionary (as in the book). For |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 499 | spelling we need a list of words that are OK, thus should not to be |
| 500 | highlighted. Person and company names will not appear in a dictionary, but do |
| 501 | appear in a word list. And some old words are rarely used while they are |
| 502 | 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] | 503 | |
Bram Moolenaar | 7d1f5db | 2005-07-03 21:39:27 +0000 | [diff] [blame] | 504 | There are two formats: A straight list of words and a list using affix |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 505 | compression. The files with affix compression are used by Myspell (Mozilla |
| 506 | and OpenOffice.org). This requires two files, one with .aff and one with .dic |
| 507 | extension. |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 508 | |
| 509 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 510 | FORMAT OF STRAIGHT WORD LIST *spell-wordlist-format* |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 511 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 512 | 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] | 513 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 514 | Additionally the following items are recognized: |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 515 | |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 516 | - Empty and blank lines are ignored. |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 517 | |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 518 | - Lines starting with a # are ignored (comment lines). |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 519 | |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 520 | - A line starting with "/encoding=", before any word, specifies the encoding |
| 521 | 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] | 522 | to setup conversion from the specified encoding to 'encoding'. Thus you can |
| 523 | use one word list for several target encodings. |
| 524 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 525 | - A line starting with "/regions=" specifies the region names that are |
| 526 | supported. Each region name must be two ASCII letters. The first one is |
| 527 | 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] | 528 | In an addition word list the region names should be equal to the main word |
| 529 | list! |
| 530 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 531 | - Other lines starting with '/' are reserved for future use. The ones that |
| 532 | are not recognized are ignored (but you do get a warning message). |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 533 | |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 534 | - A "/" may follow the word with the following items: |
| 535 | = Case must match exactly. |
| 536 | ? Rare word. |
| 537 | ! Bad (wrong) word. |
| 538 | digit A region in which the word is valid. If no regions are |
| 539 | specified the word is valid in all regions. |
| 540 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 541 | Example: |
| 542 | |
| 543 | # This is an example word list comment |
| 544 | /encoding=latin1 encoding of the file |
| 545 | /regions=uscagb regions "us", "ca" and "gb" |
| 546 | example word for all regions |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 547 | blah/12 word for regions "us" and "ca" |
| 548 | vim/! bad word |
| 549 | Campbell/?3 rare word in region 3 "gb" |
| 550 | 's mornings/= keep-case word |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 551 | |
Bram Moolenaar | 0dc065e | 2005-07-04 22:49:24 +0000 | [diff] [blame] | 552 | Note that when "/=" is used the same word with all upper-case letters is not |
| 553 | accepted. This is different from a word with mixed case that is automatically |
| 554 | marked as keep-case, those words may appear in all upper-case letters. |
| 555 | |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 556 | |
| 557 | FORMAT WITH AFFIX COMPRESSION |
| 558 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 559 | There are two files: the basic word list and an affix file. The affixes are |
| 560 | used to modify the basic words to get the full word list. This significantly |
| 561 | reduces the number of words, especially for a language like Polish. This is |
| 562 | called affix compression. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 563 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 564 | The format for the affix and word list files is mostly identical to what |
| 565 | Myspell uses (the spell checker of Mozilla and OpenOffice.org). A description |
| 566 | can be found here: |
| 567 | http://lingucomponent.openoffice.org/affix.readme ~ |
| 568 | 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] | 569 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 570 | Vim supports a few extras. Hopefully Myspell will support these too some day. |
| 571 | See |spell-affix-vim|. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 572 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 573 | The basic word list and the affix file are combined and turned into a binary |
| 574 | spell file. All the preprocessing has been done, thus this file loads fast. |
| 575 | The binary spell file format is described in the source code (src/spell.c). |
| 576 | But only developers need to know about it. |
| 577 | |
| 578 | The preprocessing also allows us to take the Myspell language files and modify |
| 579 | them before the Vim word list is made. The tools for this can be found in the |
| 580 | "src/spell" directory. |
| 581 | |
| 582 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 583 | WORD LIST FORMAT *spell-dic-format* |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 584 | |
| 585 | A very short example, with line numbers: |
| 586 | |
| 587 | 1 1234 |
| 588 | 2 aan |
| 589 | 3 Als |
| 590 | 4 Etten-Leur |
| 591 | 5 et al. |
| 592 | 6 's-Gravenhage |
| 593 | 7 's-Gravenhaags |
| 594 | 8 bedel/P |
| 595 | 9 kado/1 |
| 596 | 10 cadeau/2 |
| 597 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 598 | The first line contains the number of words. Vim ignores it, but you do get |
| 599 | an error message if it's not there. *E760* |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 600 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 601 | What follows is one word per line. There should be no white space before or |
| 602 | after the word. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 603 | |
| 604 | When the word only has lower-case letters it will also match with the word |
| 605 | starting with an upper-case letter. |
| 606 | |
| 607 | When the word includes an upper-case letter, this means the upper-case letter |
| 608 | is required at this position. The same word with a lower-case letter at this |
| 609 | position will not match. When some of the other letters are upper-case it will |
| 610 | not match either. |
| 611 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 612 | The word with all upper-case characters will always be OK. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 613 | |
| 614 | word list matches does not match ~ |
| 615 | als als Als ALS ALs AlS aLs aLS |
| 616 | Als Als ALS als ALs AlS aLs aLS |
| 617 | ALS ALS als Als ALs AlS aLs aLS |
| 618 | AlS AlS ALS als Als ALs aLs aLS |
| 619 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 620 | 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] | 621 | only, see below |spell-affix-KEP|. |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 622 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 623 | Note in line 5 to 7 that non-word characters are used. You can include |
| 624 | any character in a word. When checking the text a word still only matches |
| 625 | when it appears with a non-word character before and after it. For Myspell a |
| 626 | word starting with a non-word character probably won't work. |
| 627 | |
| 628 | 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] | 629 | letters that indicate the affixes that can be used with this word. These are |
| 630 | specified with SFX and PFX lines in the .aff file. See the Myspell |
| 631 | documentation. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 632 | |
| 633 | *spell-affix-vim* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 634 | 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] | 635 | affix file. This has the meaning that case matters. This can be used if the |
| 636 | 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] | 637 | Example (assuming that = was used for KEP): |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 638 | |
Bram Moolenaar | 0dc065e | 2005-07-04 22:49:24 +0000 | [diff] [blame] | 639 | word list matches does not match ~ |
| 640 | 's morgens/= 's morgens 'S morgens 's Morgens 'S MORGENS |
| 641 | 's Morgens 's Morgens 'S MORGENS 'S morgens 's morgens |
| 642 | |
| 643 | The flag can also be used to avoid that the word matches when it is in all |
| 644 | upper-case letters. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 645 | |
| 646 | *spell-affix-mbyte* |
| 647 | The basic word list is normally in an 8-bit encoding, which is mentioned in |
| 648 | the affix file. The affix file must always be in the same encoding as the |
| 649 | word list. This is compatible with Myspell. For Vim the encoding may also be |
| 650 | something else, any encoding that "iconv" supports. The "SET" line must |
| 651 | 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] | 652 | possible to use more different affixes (but Myspell doesn't support that, thus |
| 653 | you may not want to use it anyway). |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 654 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 655 | |
| 656 | CHARACTER TABLES |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 657 | *spell-affix-chars* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 658 | When using an 8-bit encoding the affix file should define what characters are |
| 659 | word characters (as specified with ENC). This is because the system where |
| 660 | ":mkspell" is used may not support a locale with this encoding and isalpha() |
| 661 | won't work. For example when using "cp1250" on Unix. |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 662 | |
Bram Moolenaar | e756604 | 2005-06-17 22:00:15 +0000 | [diff] [blame] | 663 | *E761* *E762* *spell-affix-FOL* |
| 664 | *spell-affix-LOW* *spell-affix-UPP* |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 665 | Three lines in the affix file are needed. Simplistic example: |
| 666 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 667 | FOL áëñ ~ |
| 668 | LOW áëñ ~ |
| 669 | UPP ÁËÑ ~ |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 670 | |
| 671 | All three lines must have exactly the same number of characters. |
| 672 | |
| 673 | The "FOL" line specifies the case-folded characters. These are used to |
| 674 | compare words while ignoring case. For most encodings this is identical to |
| 675 | the lower case line. |
| 676 | |
| 677 | The "LOW" line specifies the characters in lower-case. Mostly it's equal to |
| 678 | the "FOL" line. |
| 679 | |
| 680 | The "UPP" line specifies the characters with upper-case. That is, a character |
| 681 | is upper-case where it's different from the character at the same position in |
| 682 | "FOL". |
| 683 | |
| 684 | ASCII characters should be omitted, Vim always handles these in the same way. |
| 685 | When the encoding is UTF-8 no word characters need to be specified. |
| 686 | |
| 687 | *E763* |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 688 | Vim allows you to use spell checking for several languages in the same file. |
| 689 | You can list them in the 'spelllang' option. As a consequence all spell files |
| 690 | for the same encoding must use the same word characters, otherwise they can't |
| 691 | be combined without errors. If you get a warning that the word tables differ |
| 692 | you may need to generate the .spl file again with |:mkspell|. Check the FOL, |
| 693 | LOW and UPP lines in the used .aff file. |
| 694 | |
| 695 | The XX.ascii.spl spell file generated with the "-ascii" argument will not |
| 696 | contain the table with characters, so that it can be combine with spell files |
| 697 | 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] | 698 | |
Bram Moolenaar | e756604 | 2005-06-17 22:00:15 +0000 | [diff] [blame] | 699 | |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 700 | MID-WORD CHARACTERS |
| 701 | *spell-midword* |
| 702 | Some characters are only to be considered word characters if they are used in |
| 703 | between two ordinary word characters. An example is the single quote: It is |
| 704 | often used to put text in quotes, thus it can't be recognized as a word |
| 705 | character, but when it appears in between word characters it must be part of |
| 706 | the word. This is needed to detect a spelling error such as they'are. That |
| 707 | should be they're, but since "they" and "are" are words themselves that would |
| 708 | go unnoticed. |
| 709 | |
| 710 | These characters are defined with MIDWORD in the .aff file: |
| 711 | |
| 712 | MIDWORD '- ~ |
| 713 | |
| 714 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 715 | AFFIXES |
| 716 | *spell-affix-PFX* *spell-affix-SFX* |
| 717 | 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] | 718 | documentation or the Aspell manual: |
| 719 | http://aspell.net/man-html/Affix-Compression.html). |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 720 | |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 721 | Note that Myspell ignores any extra text after the relevant info. Vim |
| 722 | requires this text to start with a "#" so that mistakes don't go unnoticed. |
| 723 | Example: |
| 724 | |
| 725 | SFX F 0 in [^i]n # Spion > Spionin ~ |
| 726 | SFX F 0 nen in # Bauerin > Bauerinnen ~ |
| 727 | |
| 728 | An extra item for Vim is the "rare" flag. It must come after the other |
| 729 | fields, before a comment. When used then all words that use the affix will be |
| 730 | marked as rare words. Example: |
| 731 | |
| 732 | PFX F 0 nene . rare ~ |
| 733 | SFX F 0 oin n rare # hardly ever used ~ |
| 734 | |
| 735 | However, if the word also appears as a good word in another way it won't be |
| 736 | marked as rare. |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 737 | |
| 738 | *spell-affix-PFXPOSTPONE* |
| 739 | When an affix file has very many prefixes that apply to many words it's not |
| 740 | possible to build the whole word list in memory. This applies to Hebrew (a |
| 741 | list with all words is over a Gbyte). In that case applying prefixes must be |
| 742 | postponed. This makes spell checking slower. It is indicated by this keyword |
| 743 | in the .aff file: |
| 744 | |
| 745 | PFXPOSTPONE ~ |
| 746 | |
| 747 | Only prefixes without a chop string can be postponed, prefixes with a chop |
Bram Moolenaar | 78984f5 | 2005-08-01 07:19:10 +0000 | [diff] [blame] | 748 | string will still be included in the word list. An exception if the chop |
| 749 | string is one character and equal to the last character of the added string, |
| 750 | but in lower case. Thus when the chop string is used to allow the following |
| 751 | word to start with an upper case letter. |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 752 | |
Bram Moolenaar | ae5bce1 | 2005-08-15 21:41:48 +0000 | [diff] [blame^] | 753 | It is not possible to use PFXPOSTPONE together with COMPOUNDFLAG or |
| 754 | COMPOUNDFLAGS. |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 755 | |
Bram Moolenaar | ae5bce1 | 2005-08-15 21:41:48 +0000 | [diff] [blame^] | 756 | |
| 757 | WORDS WITH A SLASH *spell-affix-SLASH* |
| 758 | |
| 759 | The slash is used in the .dic file to separate the basic word from the affix |
| 760 | letters that can be used. Unfortunately, this means you cannot use a slash in |
| 761 | a word. Thus "TCP/IP" cannot be a word. To work around that you can define a |
| 762 | replacement character for the slash. Example: |
| 763 | |
| 764 | SLASH , ~ |
| 765 | |
| 766 | Now you can use "TCP,IP" to add the word "TCP/IP". |
| 767 | |
| 768 | Of course, the letter used should itself not appear in any word! The letter |
| 769 | must be ASCII, thus a single byte. |
| 770 | |
| 771 | |
| 772 | KEEP-CASE WORDS *spell-affix-KEP* |
| 773 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 774 | 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] | 775 | keep-case words. Example: |
| 776 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 777 | KEP = ~ |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 778 | |
| 779 | See above for an example |spell-affix-vim|. |
| 780 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 781 | |
Bram Moolenaar | ae5bce1 | 2005-08-15 21:41:48 +0000 | [diff] [blame^] | 782 | RARE WORDS *spell-affix-RAR* |
| 783 | |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 784 | In the affix file a RAR line can be used to define the affix name used for |
| 785 | rare words. Example: |
| 786 | |
| 787 | RAR ? ~ |
| 788 | |
| 789 | Rare words are highlighted differently from bad words. This is to be used for |
| 790 | 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] | 791 | a typing mistake anyway. When the same word is found as good it won't be |
| 792 | highlighted as rare. |
| 793 | |
| 794 | |
Bram Moolenaar | ae5bce1 | 2005-08-15 21:41:48 +0000 | [diff] [blame^] | 795 | BAD WORDS *spell-affix-BAD* |
| 796 | |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 797 | In the affix file a BAD line can be used to define the affix name used for |
| 798 | bad words. Example: |
| 799 | |
| 800 | BAD ! ~ |
| 801 | |
| 802 | 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] | 803 | "the the" in the .dic file: |
| 804 | |
| 805 | the the/! ~ |
| 806 | |
| 807 | Once a word has been marked as bad it won't be undone by encountering the same |
| 808 | word as good. |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 809 | |
| 810 | |
Bram Moolenaar | ae5bce1 | 2005-08-15 21:41:48 +0000 | [diff] [blame^] | 811 | COMPOUND WORDS *spell-affix-compound* |
| 812 | |
| 813 | A compound word is a longer word made by concatenating words. To specify |
| 814 | which words may be concatenated a character is used. This character is put in |
| 815 | the list of affixes after the word. We will call this character a flag here. |
| 816 | Obviously these flags must be different from any affix IDs used. |
| 817 | |
| 818 | *spell-COMPOUNDFLAG* |
| 819 | The Myspell compatible method uses one flag, specified with COMPOUNDFLAG. |
| 820 | All words with this flag combine in any order and without limit in length. |
| 821 | This means there is no control over which word comes first. Example: |
| 822 | COMPOUNDFLAG c ~ |
| 823 | |
| 824 | *spell-COMPOUNDFLAGS* |
| 825 | The method added by Vim allows specifying which words can be prepended to |
| 826 | other words, and which words can be appended to other words. This is a list |
| 827 | of comma separated items. Each item may contain zero or more dashes and plus |
| 828 | signs. |
| 829 | |
| 830 | NOTE: At this moment COMPOUNDFLAGS has not been implemented yet! |
| 831 | |
| 832 | An item without dashes specifies words that combine in any order and as often |
| 833 | as possible. Example: |
| 834 | COMPOUNDFLAGS c,m ~ |
| 835 | |
| 836 | This allows all words with the "c" flag to be combined and all words with the |
| 837 | "m" flag to be combined, but a word with the "c" flag doesn't combine with a |
| 838 | word with the "m" flag. |
| 839 | |
| 840 | Flags that are put together, without a separating comma, are considered |
| 841 | interchangable. Example: |
| 842 | COMPOUNDFLAGS cm ~ |
| 843 | |
| 844 | This allows all words with the "c" and/or "m" flag to be combined. |
| 845 | |
| 846 | An item with one dash specifies flags for a leading word and flags for a |
| 847 | trailing word. Thus only two-word combinations are made. Example: |
| 848 | COMPOUNDFLAGS f-d ~ |
| 849 | |
| 850 | Here the 'f' flag can be used for food and 'd' for dishes, such that you can |
| 851 | use these words in the dictionary: |
| 852 | tomato/f ~ |
| 853 | onion/f~ |
| 854 | soup/d~ |
| 855 | salat/d~ |
| 856 | |
| 857 | Which makes the words: |
| 858 | tomato |
| 859 | onion |
| 860 | soup |
| 861 | salat |
| 862 | tomatosoup |
| 863 | tomatosalat |
| 864 | onionsoup |
| 865 | onionsalat |
| 866 | |
| 867 | Note that something like "souptomato" is not possible. And that it's actually |
| 868 | easier to list all the words if you have only this few. |
| 869 | |
| 870 | More dashes can be used to allow more words to combine. For example: |
| 871 | COMPOUNDFLAGS f-d,f-f-d ~ |
| 872 | |
| 873 | Would allow "tomatoonionsoup" (OK, so this is a bad example, but you get the |
| 874 | idea). |
| 875 | |
| 876 | When a word can be used an undetermined number of times use a plus instead of |
| 877 | a dash. Example: |
| 878 | COMPOUNDFLAGS f+d ~ |
| 879 | |
| 880 | Then you can make tasty "oniononiontomatotomatosoup". |
| 881 | |
| 882 | The "+" may also appear at the end, which means that the last flags can be |
| 883 | repeated many times. Example: |
| 884 | COMPOUNDFLAGS f-d+ ~ |
| 885 | |
| 886 | Which allows the use of "onionsoupsoupsoupsoupsoupsoup". |
| 887 | |
| 888 | *spell-COMPOUNDMIN* |
| 889 | The minimal length of a word used for concatenation is specified with |
| 890 | COMPOUNDMIN. Example: |
| 891 | COMPOUNDMIN 5 ~ |
| 892 | |
| 893 | When omitted a minimal length of 3 bytes is used. Obviously you could just |
| 894 | leave out the compound flag from short words instead, this feature is present |
| 895 | for compatibility with Myspell. |
| 896 | |
| 897 | *spell-CMP* |
| 898 | NOTE: At this moment CMP has not been implemented yet! |
| 899 | |
| 900 | Sometimes it is necessary to change a word when concatenating it to another, |
| 901 | by removing a few letters, inserting something or both. It can also be useful |
| 902 | to restrict concatenation to words that match a pattern. For this purpose CMP |
| 903 | items can be used. They look like this: |
| 904 | CMP {flag} {strip} {add} {cond} {cond2} |
| 905 | |
| 906 | {flag} the flag, as used in COMPOUNDFLAGS for the lead word |
| 907 | {strip} text to remove from the end of the lead word (zero |
| 908 | for no stripping) |
| 909 | {add} text to insert between the words (zero for no |
| 910 | addition) |
| 911 | {cond} condition to match at the end of the lead word |
| 912 | {cond2} condition to match at the start of the following word |
| 913 | |
| 914 | This is exactly the same as what is used for SFX and PFX items, except there |
| 915 | is an extra condition. Example: |
| 916 | CMP f 0 - . . ~ |
| 917 | |
| 918 | When used with the food and dish word list above, this means that a dash is |
| 919 | inserted after each food item. Thus you get "onion-soup" and |
| 920 | "onion-tomato-salat". |
| 921 | |
| 922 | When there are CMP items for a compound flag the concatenation is only done |
| 923 | when a CMP item matches. |
| 924 | |
| 925 | When there are no CMP items for a compound flag, then all words will be |
| 926 | concatenated, as if there was an item: |
| 927 | CMP {flag} 0 0 . . |
| 928 | |
| 929 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 930 | REPLACEMENTS *spell-affix-REP* |
| 931 | |
| 932 | In the affix file REP items can be used to define common mistakes. This is |
| 933 | used to make spelling suggestions. The items define the "from" text and the |
| 934 | "to" replacement. Example: |
| 935 | |
| 936 | REP 4 ~ |
| 937 | REP f ph ~ |
| 938 | REP ph f ~ |
| 939 | REP k ch ~ |
| 940 | REP ch k ~ |
| 941 | |
| 942 | 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] | 943 | Don't include simple one-character replacements or swaps. Vim will try these |
| 944 | anyway. You can include whole words if you want to, but you might want to use |
| 945 | the "file:" item in 'spellsuggest' instead. |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 946 | |
| 947 | |
| 948 | SIMILAR CHARACTERS *spell-affix-MAP* |
| 949 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 950 | 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] | 951 | alike. This is mostly used for a letter with different accents. This is used |
| 952 | to prefer suggestions with these letters substituted. Example: |
| 953 | |
| 954 | MAP 2 ~ |
| 955 | MAP eéëêè ~ |
| 956 | MAP uüùúû ~ |
| 957 | |
| 958 | The first line specifies the number of MAP lines following. Vim ignores it. |
| 959 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 960 | Each letter must appear in only one of the MAP items. It's a bit more |
| 961 | 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] | 962 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 963 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 964 | SOUND-A-LIKE *spell-affix-SAL* |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 965 | |
| 966 | In the affix file SAL items can be used to define the sounds-a-like mechanism |
| 967 | 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] | 968 | Simplistic example: |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 969 | |
| 970 | SAL CIA X ~ |
| 971 | SAL CH X ~ |
| 972 | SAL C K ~ |
| 973 | SAL K K ~ |
| 974 | |
Bram Moolenaar | 7d1f5db | 2005-07-03 21:39:27 +0000 | [diff] [blame] | 975 | There are a few rules and this can become quite complicated. An explanation |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 976 | how it works can be found in the Aspell manual: |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 977 | http://aspell.net/man-html/Phonetic-Code.html. |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 978 | |
| 979 | There are a few special items: |
| 980 | |
| 981 | SAL followup true ~ |
| 982 | SAL collapse_result true ~ |
| 983 | SAL remove_accents true ~ |
| 984 | |
| 985 | "1" has the same meaning as "true". Any other value means "false". |
| 986 | |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 987 | |
| 988 | SIMPLE SOUNDFOLDING *spell-affix-SOFOFROM* *spell-affix-SOFOTO* |
| 989 | |
| 990 | The SAL mechanism is complex and slow. A simpler mechanism is mapping all |
| 991 | characters to another character, mapping similar sounding characters to the |
| 992 | 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] | 993 | both SAL items and simple soundfolding. |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 994 | |
Bram Moolenaar | 7d1f5db | 2005-07-03 21:39:27 +0000 | [diff] [blame] | 995 | There are two items required: one to specify the characters that are mapped |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 996 | and one that specifies the characters they are mapped to. They must have |
| 997 | exactly the same number of characters. Example: |
| 998 | |
| 999 | SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~ |
| 1000 | SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkes ~ |
| 1001 | |
| 1002 | 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] | 1003 | method would be to leave out all vowels. Some characters that sound nearly |
| 1004 | the same and are often mixed up, such as 'm' and 'n', are mapped to the same |
| 1005 | 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] | 1006 | |
| 1007 | Characters that do not appear in SOFOFROM will be left out, except that all |
| 1008 | white space is replaced by one space. Sequences of the same character in |
| 1009 | SOFOFROM are replaced by one. |
| 1010 | |
| 1011 | You can use the |soundfold()| function to try out the results. Or set the |
| 1012 | 'verbose' option to see the score in the output of the |z?| command. |
| 1013 | |
| 1014 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 1015 | vim:tw=78:sw=4:ts=8:ft=help:norl: |