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