Bram Moolenaar | 90cfdbe | 2005-08-12 19:59:19 +0000 | [diff] [blame^] | 1 | *spell.txt* For Vim version 7.0aa. Last change: 2005 Aug 12 |
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 | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 198 | |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 199 | SPELL FILES *spell-load* |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 200 | |
| 201 | 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] | 202 | 'runtimepath'. The name is: LL.EEE.spl, where: |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 203 | LL the language name |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 204 | EEE the value of 'encoding' |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 205 | |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 206 | The value for "LL" comes from 'spelllang', but excludes the region name. |
| 207 | Examples: |
| 208 | 'spelllang' LL ~ |
| 209 | en_us en |
| 210 | en-rare en-rare |
| 211 | medical_ca medical |
| 212 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 213 | Only the first file is loaded, the one that is first in 'runtimepath'. If |
| 214 | this succeeds then additionally files with the name LL.EEE.add.spl are loaded. |
| 215 | All the ones that are found are used. |
| 216 | |
Bram Moolenaar | 0d9c26d | 2005-07-02 23:19:16 +0000 | [diff] [blame] | 217 | Additionally, the files related to the names in 'spellfile' are loaded. These |
| 218 | 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] | 219 | |
Bram Moolenaar | 0e21a3f | 2005-04-17 20:28:32 +0000 | [diff] [blame] | 220 | Exceptions: |
| 221 | - Vim uses "latin1" when 'encoding' is "iso-8859-15". The euro sign doesn't |
| 222 | matter for spelling. |
| 223 | - When no spell file for 'encoding' is found "ascii" is tried. This only |
| 224 | works for languages where nearly all words are ASCII, such as English. It |
| 225 | 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] | 226 | is being edited. For the ".add" files the same name as the found main |
| 227 | spell file is used. |
| 228 | |
| 229 | For example, with these values: |
| 230 | 'runtimepath' is "~/.vim,/usr/share/vim70,~/.vim/after" |
| 231 | 'encoding' is "iso-8859-2" |
| 232 | 'spelllang' is "pl" |
| 233 | |
| 234 | Vim will look for: |
| 235 | 1. ~/.vim/spell/pl.iso-8859-2.spl |
| 236 | 2. /usr/share/vim70/spell/pl.iso-8859-2.spl |
| 237 | 3. ~/.vim/spell/pl.iso-8859-2.add.spl |
| 238 | 4. /usr/share/vim70/spell/pl.iso-8859-2.add.spl |
| 239 | 5. ~/.vim/after/spell/pl.iso-8859-2.add.spl |
| 240 | |
| 241 | This assumes 1. is not found and 2. is found. |
| 242 | |
| 243 | If 'encoding' is "latin1" Vim will look for: |
| 244 | 1. ~/.vim/spell/pl.latin1.spl |
| 245 | 2. /usr/share/vim70/spell/pl.latin1.spl |
| 246 | 3. ~/.vim/after/spell/pl.latin1.spl |
| 247 | 4. ~/.vim/spell/pl.ascii.spl |
| 248 | 5. /usr/share/vim70/spell/pl.ascii.spl |
| 249 | 6. ~/.vim/after/spell/pl.ascii.spl |
| 250 | |
| 251 | This assumes none of them are found (Polish doesn't make sense when leaving |
| 252 | out the non-ASCII characters). |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 253 | |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 254 | Spelling for EBCDIC is currently not supported. |
| 255 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 256 | A spell file might not be available in the current 'encoding'. See |
| 257 | |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] | 258 | with "iconv" will NOT work! |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 259 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 260 | *E758* *E759* |
| 261 | 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] | 262 | get an error the file may be truncated, modified or intended for another Vim |
| 263 | version. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 264 | |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 265 | |
| 266 | WORDS |
| 267 | |
| 268 | Vim uses a fixed method to recognize a word. This is independent of |
| 269 | 'iskeyword', so that it also works in help files and for languages that |
| 270 | include characters like '-' in 'iskeyword'. The word characters do depend on |
| 271 | 'encoding'. |
| 272 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 273 | The table with word characters is stored in the main .spl file. Therefore it |
| 274 | 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] | 275 | not contain a word table though. |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 276 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 277 | A word that starts with a digit is always ignored. That includes hex numbers |
| 278 | in the form 0xff and 0XFF. |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 279 | |
| 280 | |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 281 | WORD COMBINATIONS |
| 282 | |
| 283 | It is possible to spell-check words that include a space. This is used to |
| 284 | recognize words that are invalid when used by themselves, e.g. for "et al.". |
| 285 | It can also be used to recognize "the the" and highlight it. |
| 286 | |
| 287 | The number of spaces is irrelevant. In most cases a line break may also |
| 288 | appear. However, this makes it difficult to find out where to start checking |
| 289 | for spelling mistakes. When you make a change to one line and only that line |
| 290 | is redrawn Vim won't look in the previous line, thus when "et" is at the end |
| 291 | of the previous line "al." will be flagged as an error. And when you type |
| 292 | "the<CR>the" the highlighting doesn't appear until the first line is redrawn. |
| 293 | Use |CTRL-L| to redraw right away. "[s" will also stop at a word combination |
| 294 | with a line break. |
| 295 | |
| 296 | When encountering a line break Vim skips characters such as '*', '>' and '"', |
| 297 | so that comments in C, shell and Vim code can be spell checked. |
| 298 | |
| 299 | |
Bram Moolenaar | 9d0ec2e | 2005-04-20 19:45:58 +0000 | [diff] [blame] | 300 | SYNTAX HIGHLIGHTING *spell-syntax* |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 301 | |
| 302 | Files that use syntax highlighting can specify where spell checking should be |
| 303 | done: |
| 304 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 305 | 1. everywhere default |
| 306 | 2. in specific items use "contains=@Spell" |
| 307 | 3. everywhere but specific items use "contains=@NoSpell" |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 308 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 309 | For the second method adding the @NoSpell cluster will disable spell checking |
| 310 | again. This can be used, for example, to add @Spell to the comments of a |
| 311 | program, and add @NoSpell for items that shouldn't be checked. |
Bram Moolenaar | 6bb6836 | 2005-03-22 23:03:44 +0000 | [diff] [blame] | 312 | |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 313 | |
| 314 | VIM SCRIPTS |
| 315 | |
| 316 | If you want to write a Vim script that does something with spelling, you may |
| 317 | find these functions useful: |
| 318 | |
| 319 | spellbadword() find badly spelled word at the cursor |
| 320 | spellsuggest() get list of spelling suggestions |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 321 | soundfold() get the sound-a-like version of a word |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 322 | |
Bram Moolenaar | 90cfdbe | 2005-08-12 19:59:19 +0000 | [diff] [blame^] | 323 | |
| 324 | SETTING 'spellcapcheck' AUTOMATICALLY *set-spc-auto* |
| 325 | |
| 326 | After the 'spelllang' option has been set successfully, Vim will source the |
| 327 | files "spell/LANG.vim" in 'runtimepath'. "LANG" is the value of 'spelllang' |
| 328 | up to the first comma, dot or underscore. This can be used to set options |
| 329 | specifically for the language, especially 'spellcapcheck'. |
| 330 | |
| 331 | The distribution includes a few of these files. Use this command to see what |
| 332 | they do: > |
| 333 | :next $VIMRUNTIME/spell/*.vim |
| 334 | |
| 335 | Note that the default scripts don't set 'spellcapcheck' if it was changed from |
| 336 | the default value. This assumes the user prefers another value then. |
| 337 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 338 | ============================================================================== |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 339 | 3. Generating a spell file *spell-mkspell* |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 340 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 341 | Vim uses a binary file format for spelling. This greatly speeds up loading |
| 342 | the word list and keeps it small. |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 343 | *.aff* *.dic* *Myspell* |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 344 | You can create a Vim spell file from the .aff and .dic files that Myspell |
| 345 | uses. Myspell is used by OpenOffice.org and Mozilla. You should be able to |
| 346 | find them here: |
| 347 | http://lingucomponent.openoffice.org/spell_dic.html |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 348 | 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] | 349 | depends on what word lists you can find. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 350 | |
Bram Moolenaar | 7d1f5db | 2005-07-03 21:39:27 +0000 | [diff] [blame] | 351 | If you install Aap (from www.a-a-p.org) you can use the recipes in the |
| 352 | runtime/spell/??/ directories. Aap will take care of downloading the files, |
| 353 | apply patches needed for Vim and build the .spl file. |
| 354 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 355 | Make sure your current locale is set properly, otherwise Vim doesn't know what |
| 356 | characters are upper/lower case letters. If the locale isn't available (e.g., |
| 357 | 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] | 358 | |spell-affix-chars|. If the .aff file doesn't define a table then the word |
| 359 | table of the currently active spelling is used. If spelling is not active |
| 360 | then Vim will try to guess. |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 361 | |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 362 | *:mksp* *:mkspell* |
| 363 | :mksp[ell][!] [-ascii] {outname} {inname} ... |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 364 | Generate a Vim spell file word lists. Example: > |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 365 | :mkspell /tmp/nl nl_NL.words |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 366 | < *E751* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 367 | When {outname} ends in ".spl" it is used as the output |
| 368 | file name. Otherwise it should be a language name, |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 369 | such as "en", without the region name. The file |
| 370 | written will be "{outname}.{encoding}.spl", where |
| 371 | {encoding} is the value of the 'encoding' option. |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 372 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 373 | When the output file already exists [!] must be used |
Bram Moolenaar | 520470a | 2005-06-16 21:59:56 +0000 | [diff] [blame] | 374 | to overwrite it. |
| 375 | |
Bram Moolenaar | 0e21a3f | 2005-04-17 20:28:32 +0000 | [diff] [blame] | 376 | When the [-ascii] argument is present, words with |
| 377 | non-ascii characters are skipped. The resulting file |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 378 | ends in "ascii.spl". |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 379 | |
| 380 | The input can be the Myspell format files {inname}.aff |
| 381 | and {inname}.dic. If {inname}.aff does not exist then |
| 382 | {inname} is used as the file name of a plain word |
| 383 | list. |
| 384 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 385 | Multiple {inname} arguments can be given to combine |
| 386 | regions into one Vim spell file. Example: > |
| 387 | :mkspell ~/.vim/spell/en /tmp/en_US /tmp/en_CA /tmp/en_AU |
| 388 | < This combines the English word lists for US, CA and AU |
| 389 | into one en.spl file. |
| 390 | Up to eight regions can be combined. *E754* *755* |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 391 | The REP and SAL items of the first .aff file where |
| 392 | they appear are used. |spell-affix-REP| |
| 393 | |spell-affix-SAL| |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 394 | |
Bram Moolenaar | 30abd28 | 2005-06-22 22:35:10 +0000 | [diff] [blame] | 395 | This command uses a lot of memory, required to find |
| 396 | the optimal word tree (Polish requires a few hundred |
| 397 | Mbyte). The final result will be much smaller. |
| 398 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 399 | After the spell file was written and it was being used |
| 400 | in a buffer it will be reloaded automatically. |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 401 | |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 402 | :mksp[ell] [-ascii] {name}.{enc}.add |
| 403 | Like ":mkspell" above, using {name}.{enc}.add as the |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 404 | input file and producing an output file in the same |
| 405 | directory that has ".spl" appended. |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 406 | |
| 407 | :mksp[ell] [-ascii] {name} |
| 408 | Like ":mkspell" above, using {name} as the input file |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 409 | and producing an output file in the same directory |
| 410 | that has ".{enc}.spl" appended. |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 411 | |
| 412 | Since you might want to change a Myspell word list for use with Vim the |
| 413 | following procedure is recommended: |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 414 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 415 | 1. Obtain the xx_YY.aff and xx_YY.dic files from Myspell. |
| 416 | 2. Make a copy of these files to xx_YY.orig.aff and xx_YY.orig.dic. |
| 417 | 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] | 418 | words, define word characters with FOL/LOW/UPP, etc. The distributed |
| 419 | "src/spell/*.diff" files can be used. |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 420 | 4. Start Vim with the right locale and use |:mkspell| to generate the Vim |
| 421 | spell file. |
| 422 | 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] | 423 | 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] | 424 | wrote it somewhere else. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 425 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 426 | When the Myspell files are updated you can merge the differences: |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 427 | 1. Obtain the new Myspell files as xx_YY.new.aff and xx_UU.new.dic. |
| 428 | 2. Use Vimdiff to see what changed: > |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 429 | vimdiff xx_YY.orig.dic xx_YY.new.dic |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 430 | 3. Take over the changes you like in xx_YY.dic. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 431 | You may also need to change xx_YY.aff. |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 432 | 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] | 433 | |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 434 | |
| 435 | SPELL FILE DUMP |
| 436 | |
| 437 | If for some reason you want to check what words are supported by the currently |
| 438 | used spelling files, use this command: |
| 439 | |
| 440 | *:spelldump* *:spelld* |
| 441 | :spelld[ump] Open a new window and fill it with all currently valid |
| 442 | words. |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 443 | Note: For some languages the result may be enormous, |
| 444 | causing Vim to run out of memory. |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 445 | |
| 446 | The format of the word list is used |spell-wordlist-format|. You should be |
| 447 | able to read it with ":mkspell" to generate one .spl file that includes all |
| 448 | the words. |
| 449 | |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 450 | When all entries to 'spelllang' use the same regions or no regions at all then |
| 451 | the region information is included in the dumped words. Otherwise only words |
| 452 | for the current region are included and no "/regions" line is generated. |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 453 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 454 | Comment lines with the name of the .spl file are used as a header above the |
| 455 | words that were generated from that .spl file. |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 456 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 457 | ============================================================================== |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 458 | 4. Spell file format *spell-file-format* |
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 | This is the format of the files that are used by the person who creates and |
| 461 | maintains a word list. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 462 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 463 | Note that we avoid the word "dictionary" here. That is because the goal of |
| 464 | spell checking differs from writing a dictionary (as in the book). For |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 465 | spelling we need a list of words that are OK, thus should not to be |
| 466 | highlighted. Person and company names will not appear in a dictionary, but do |
| 467 | appear in a word list. And some old words are rarely used while they are |
| 468 | 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] | 469 | |
Bram Moolenaar | 7d1f5db | 2005-07-03 21:39:27 +0000 | [diff] [blame] | 470 | 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] | 471 | compression. The files with affix compression are used by Myspell (Mozilla |
| 472 | and OpenOffice.org). This requires two files, one with .aff and one with .dic |
| 473 | extension. |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 474 | |
| 475 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 476 | FORMAT OF STRAIGHT WORD LIST *spell-wordlist-format* |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 477 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 478 | 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] | 479 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 480 | Additionally the following items are recognized: |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 481 | |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 482 | - Empty and blank lines are ignored. |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 483 | |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 484 | - Lines starting with a # are ignored (comment lines). |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 485 | |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 486 | - A line starting with "/encoding=", before any word, specifies the encoding |
| 487 | 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] | 488 | to setup conversion from the specified encoding to 'encoding'. Thus you can |
| 489 | use one word list for several target encodings. |
| 490 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 491 | - A line starting with "/regions=" specifies the region names that are |
| 492 | supported. Each region name must be two ASCII letters. The first one is |
| 493 | 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] | 494 | In an addition word list the region names should be equal to the main word |
| 495 | list! |
| 496 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 497 | - Other lines starting with '/' are reserved for future use. The ones that |
| 498 | are not recognized are ignored (but you do get a warning message). |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 499 | |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 500 | - A "/" may follow the word with the following items: |
| 501 | = Case must match exactly. |
| 502 | ? Rare word. |
| 503 | ! Bad (wrong) word. |
| 504 | digit A region in which the word is valid. If no regions are |
| 505 | specified the word is valid in all regions. |
| 506 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 507 | Example: |
| 508 | |
| 509 | # This is an example word list comment |
| 510 | /encoding=latin1 encoding of the file |
| 511 | /regions=uscagb regions "us", "ca" and "gb" |
| 512 | example word for all regions |
Bram Moolenaar | 1f8a5f0 | 2005-07-01 22:41:52 +0000 | [diff] [blame] | 513 | blah/12 word for regions "us" and "ca" |
| 514 | vim/! bad word |
| 515 | Campbell/?3 rare word in region 3 "gb" |
| 516 | 's mornings/= keep-case word |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 517 | |
Bram Moolenaar | 0dc065e | 2005-07-04 22:49:24 +0000 | [diff] [blame] | 518 | Note that when "/=" is used the same word with all upper-case letters is not |
| 519 | accepted. This is different from a word with mixed case that is automatically |
| 520 | marked as keep-case, those words may appear in all upper-case letters. |
| 521 | |
Bram Moolenaar | 75c50c4 | 2005-06-04 22:06:24 +0000 | [diff] [blame] | 522 | |
| 523 | FORMAT WITH AFFIX COMPRESSION |
| 524 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 525 | There are two files: the basic word list and an affix file. The affixes are |
| 526 | used to modify the basic words to get the full word list. This significantly |
| 527 | reduces the number of words, especially for a language like Polish. This is |
| 528 | called affix compression. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 529 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 530 | The format for the affix and word list files is mostly identical to what |
| 531 | Myspell uses (the spell checker of Mozilla and OpenOffice.org). A description |
| 532 | can be found here: |
| 533 | http://lingucomponent.openoffice.org/affix.readme ~ |
| 534 | 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] | 535 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 536 | Vim supports a few extras. Hopefully Myspell will support these too some day. |
| 537 | See |spell-affix-vim|. |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 538 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 539 | The basic word list and the affix file are combined and turned into a binary |
| 540 | spell file. All the preprocessing has been done, thus this file loads fast. |
| 541 | The binary spell file format is described in the source code (src/spell.c). |
| 542 | But only developers need to know about it. |
| 543 | |
| 544 | The preprocessing also allows us to take the Myspell language files and modify |
| 545 | them before the Vim word list is made. The tools for this can be found in the |
| 546 | "src/spell" directory. |
| 547 | |
| 548 | |
Bram Moolenaar | 3638c68 | 2005-06-08 22:05:14 +0000 | [diff] [blame] | 549 | WORD LIST FORMAT *spell-dic-format* |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 550 | |
| 551 | A very short example, with line numbers: |
| 552 | |
| 553 | 1 1234 |
| 554 | 2 aan |
| 555 | 3 Als |
| 556 | 4 Etten-Leur |
| 557 | 5 et al. |
| 558 | 6 's-Gravenhage |
| 559 | 7 's-Gravenhaags |
| 560 | 8 bedel/P |
| 561 | 9 kado/1 |
| 562 | 10 cadeau/2 |
| 563 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 564 | The first line contains the number of words. Vim ignores it, but you do get |
| 565 | an error message if it's not there. *E760* |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 566 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 567 | What follows is one word per line. There should be no white space before or |
| 568 | after the word. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 569 | |
| 570 | When the word only has lower-case letters it will also match with the word |
| 571 | starting with an upper-case letter. |
| 572 | |
| 573 | When the word includes an upper-case letter, this means the upper-case letter |
| 574 | is required at this position. The same word with a lower-case letter at this |
| 575 | position will not match. When some of the other letters are upper-case it will |
| 576 | not match either. |
| 577 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 578 | The word with all upper-case characters will always be OK. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 579 | |
| 580 | word list matches does not match ~ |
| 581 | als als Als ALS ALs AlS aLs aLS |
| 582 | Als Als ALS als ALs AlS aLs aLS |
| 583 | ALS ALS als Als ALs AlS aLs aLS |
| 584 | AlS AlS ALS als Als ALs aLs aLS |
| 585 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 586 | 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] | 587 | only, see below |spell-affix-KEP|. |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 588 | |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 589 | Note in line 5 to 7 that non-word characters are used. You can include |
| 590 | any character in a word. When checking the text a word still only matches |
| 591 | when it appears with a non-word character before and after it. For Myspell a |
| 592 | word starting with a non-word character probably won't work. |
| 593 | |
| 594 | 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] | 595 | letters that indicate the affixes that can be used with this word. These are |
| 596 | specified with SFX and PFX lines in the .aff file. See the Myspell |
| 597 | documentation. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 598 | |
| 599 | *spell-affix-vim* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 600 | 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] | 601 | affix file. This has the meaning that case matters. This can be used if the |
| 602 | 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] | 603 | Example (assuming that = was used for KEP): |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 604 | |
Bram Moolenaar | 0dc065e | 2005-07-04 22:49:24 +0000 | [diff] [blame] | 605 | word list matches does not match ~ |
| 606 | 's morgens/= 's morgens 'S morgens 's Morgens 'S MORGENS |
| 607 | 's Morgens 's Morgens 'S MORGENS 'S morgens 's morgens |
| 608 | |
| 609 | The flag can also be used to avoid that the word matches when it is in all |
| 610 | upper-case letters. |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 611 | |
| 612 | *spell-affix-mbyte* |
| 613 | The basic word list is normally in an 8-bit encoding, which is mentioned in |
| 614 | the affix file. The affix file must always be in the same encoding as the |
| 615 | word list. This is compatible with Myspell. For Vim the encoding may also be |
| 616 | something else, any encoding that "iconv" supports. The "SET" line must |
| 617 | 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] | 618 | possible to use more different affixes (but Myspell doesn't support that, thus |
| 619 | you may not want to use it anyway). |
Bram Moolenaar | 13fcaaf | 2005-04-15 21:13:42 +0000 | [diff] [blame] | 620 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 621 | |
| 622 | CHARACTER TABLES |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 623 | *spell-affix-chars* |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 624 | When using an 8-bit encoding the affix file should define what characters are |
| 625 | word characters (as specified with ENC). This is because the system where |
| 626 | ":mkspell" is used may not support a locale with this encoding and isalpha() |
| 627 | won't work. For example when using "cp1250" on Unix. |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 628 | |
Bram Moolenaar | e756604 | 2005-06-17 22:00:15 +0000 | [diff] [blame] | 629 | *E761* *E762* *spell-affix-FOL* |
| 630 | *spell-affix-LOW* *spell-affix-UPP* |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 631 | Three lines in the affix file are needed. Simplistic example: |
| 632 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 633 | FOL áëñ ~ |
| 634 | LOW áëñ ~ |
| 635 | UPP ÁËÑ ~ |
Bram Moolenaar | 0cb032e | 2005-04-23 20:52:00 +0000 | [diff] [blame] | 636 | |
| 637 | All three lines must have exactly the same number of characters. |
| 638 | |
| 639 | The "FOL" line specifies the case-folded characters. These are used to |
| 640 | compare words while ignoring case. For most encodings this is identical to |
| 641 | the lower case line. |
| 642 | |
| 643 | The "LOW" line specifies the characters in lower-case. Mostly it's equal to |
| 644 | the "FOL" line. |
| 645 | |
| 646 | The "UPP" line specifies the characters with upper-case. That is, a character |
| 647 | is upper-case where it's different from the character at the same position in |
| 648 | "FOL". |
| 649 | |
| 650 | ASCII characters should be omitted, Vim always handles these in the same way. |
| 651 | When the encoding is UTF-8 no word characters need to be specified. |
| 652 | |
| 653 | *E763* |
Bram Moolenaar | 3b50694 | 2005-06-23 22:36:45 +0000 | [diff] [blame] | 654 | Vim allows you to use spell checking for several languages in the same file. |
| 655 | You can list them in the 'spelllang' option. As a consequence all spell files |
| 656 | for the same encoding must use the same word characters, otherwise they can't |
| 657 | be combined without errors. If you get a warning that the word tables differ |
| 658 | you may need to generate the .spl file again with |:mkspell|. Check the FOL, |
| 659 | LOW and UPP lines in the used .aff file. |
| 660 | |
| 661 | The XX.ascii.spl spell file generated with the "-ascii" argument will not |
| 662 | contain the table with characters, so that it can be combine with spell files |
| 663 | 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] | 664 | |
Bram Moolenaar | e756604 | 2005-06-17 22:00:15 +0000 | [diff] [blame] | 665 | |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 666 | MID-WORD CHARACTERS |
| 667 | *spell-midword* |
| 668 | Some characters are only to be considered word characters if they are used in |
| 669 | between two ordinary word characters. An example is the single quote: It is |
| 670 | often used to put text in quotes, thus it can't be recognized as a word |
| 671 | character, but when it appears in between word characters it must be part of |
| 672 | the word. This is needed to detect a spelling error such as they'are. That |
| 673 | should be they're, but since "they" and "are" are words themselves that would |
| 674 | go unnoticed. |
| 675 | |
| 676 | These characters are defined with MIDWORD in the .aff file: |
| 677 | |
| 678 | MIDWORD '- ~ |
| 679 | |
| 680 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 681 | AFFIXES |
| 682 | *spell-affix-PFX* *spell-affix-SFX* |
| 683 | 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] | 684 | documentation or the Aspell manual: |
| 685 | http://aspell.net/man-html/Affix-Compression.html). |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 686 | |
Bram Moolenaar | 9a50b1b | 2005-06-27 22:48:21 +0000 | [diff] [blame] | 687 | Note that Myspell ignores any extra text after the relevant info. Vim |
| 688 | requires this text to start with a "#" so that mistakes don't go unnoticed. |
| 689 | Example: |
| 690 | |
| 691 | SFX F 0 in [^i]n # Spion > Spionin ~ |
| 692 | SFX F 0 nen in # Bauerin > Bauerinnen ~ |
| 693 | |
| 694 | An extra item for Vim is the "rare" flag. It must come after the other |
| 695 | fields, before a comment. When used then all words that use the affix will be |
| 696 | marked as rare words. Example: |
| 697 | |
| 698 | PFX F 0 nene . rare ~ |
| 699 | SFX F 0 oin n rare # hardly ever used ~ |
| 700 | |
| 701 | However, if the word also appears as a good word in another way it won't be |
| 702 | marked as rare. |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 703 | |
| 704 | *spell-affix-PFXPOSTPONE* |
| 705 | When an affix file has very many prefixes that apply to many words it's not |
| 706 | possible to build the whole word list in memory. This applies to Hebrew (a |
| 707 | list with all words is over a Gbyte). In that case applying prefixes must be |
| 708 | postponed. This makes spell checking slower. It is indicated by this keyword |
| 709 | in the .aff file: |
| 710 | |
| 711 | PFXPOSTPONE ~ |
| 712 | |
| 713 | 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] | 714 | string will still be included in the word list. An exception if the chop |
| 715 | string is one character and equal to the last character of the added string, |
| 716 | but in lower case. Thus when the chop string is used to allow the following |
| 717 | word to start with an upper case letter. |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 718 | |
| 719 | |
| 720 | KEEP-CASE WORDS |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 721 | *spell-affix-KEP* |
| 722 | 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] | 723 | keep-case words. Example: |
| 724 | |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 725 | KEP = ~ |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 726 | |
| 727 | See above for an example |spell-affix-vim|. |
| 728 | |
Bram Moolenaar | e13305e | 2005-06-19 22:54:15 +0000 | [diff] [blame] | 729 | |
| 730 | RARE WORDS |
Bram Moolenaar | 82cf9b6 | 2005-06-07 21:09:25 +0000 | [diff] [blame] | 731 | *spell-affix-RAR* |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 732 | In the affix file a RAR line can be used to define the affix name used for |
| 733 | rare words. Example: |
| 734 | |
| 735 | RAR ? ~ |
| 736 | |
| 737 | Rare words are highlighted differently from bad words. This is to be used for |
| 738 | 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] | 739 | a typing mistake anyway. When the same word is found as good it won't be |
| 740 | highlighted as rare. |
| 741 | |
| 742 | |
| 743 | BAD WORDS |
| 744 | *spell-affix-BAD* |
| 745 | In the affix file a BAD line can be used to define the affix name used for |
| 746 | bad words. Example: |
| 747 | |
| 748 | BAD ! ~ |
| 749 | |
| 750 | 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] | 751 | "the the" in the .dic file: |
| 752 | |
| 753 | the the/! ~ |
| 754 | |
| 755 | Once a word has been marked as bad it won't be undone by encountering the same |
| 756 | word as good. |
Bram Moolenaar | 45eeb13 | 2005-06-06 21:59:07 +0000 | [diff] [blame] | 757 | |
| 758 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 759 | REPLACEMENTS *spell-affix-REP* |
| 760 | |
| 761 | In the affix file REP items can be used to define common mistakes. This is |
| 762 | used to make spelling suggestions. The items define the "from" text and the |
| 763 | "to" replacement. Example: |
| 764 | |
| 765 | REP 4 ~ |
| 766 | REP f ph ~ |
| 767 | REP ph f ~ |
| 768 | REP k ch ~ |
| 769 | REP ch k ~ |
| 770 | |
| 771 | 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] | 772 | Don't include simple one-character replacements or swaps. Vim will try these |
| 773 | anyway. You can include whole words if you want to, but you might want to use |
| 774 | the "file:" item in 'spellsuggest' instead. |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 775 | |
| 776 | |
| 777 | SIMILAR CHARACTERS *spell-affix-MAP* |
| 778 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 779 | 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] | 780 | alike. This is mostly used for a letter with different accents. This is used |
| 781 | to prefer suggestions with these letters substituted. Example: |
| 782 | |
| 783 | MAP 2 ~ |
| 784 | MAP eéëêè ~ |
| 785 | MAP uüùúû ~ |
| 786 | |
| 787 | The first line specifies the number of MAP lines following. Vim ignores it. |
| 788 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 789 | Each letter must appear in only one of the MAP items. It's a bit more |
| 790 | 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] | 791 | |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 792 | |
Bram Moolenaar | d042c56 | 2005-06-30 22:04:15 +0000 | [diff] [blame] | 793 | SOUND-A-LIKE *spell-affix-SAL* |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 794 | |
| 795 | In the affix file SAL items can be used to define the sounds-a-like mechanism |
| 796 | 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] | 797 | Simplistic example: |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 798 | |
| 799 | SAL CIA X ~ |
| 800 | SAL CH X ~ |
| 801 | SAL C K ~ |
| 802 | SAL K K ~ |
| 803 | |
Bram Moolenaar | 7d1f5db | 2005-07-03 21:39:27 +0000 | [diff] [blame] | 804 | 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] | 805 | how it works can be found in the Aspell manual: |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 806 | http://aspell.net/man-html/Phonetic-Code.html. |
Bram Moolenaar | 9ba0eb8 | 2005-06-13 22:28:56 +0000 | [diff] [blame] | 807 | |
| 808 | There are a few special items: |
| 809 | |
| 810 | SAL followup true ~ |
| 811 | SAL collapse_result true ~ |
| 812 | SAL remove_accents true ~ |
| 813 | |
| 814 | "1" has the same meaning as "true". Any other value means "false". |
| 815 | |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 816 | |
| 817 | SIMPLE SOUNDFOLDING *spell-affix-SOFOFROM* *spell-affix-SOFOTO* |
| 818 | |
| 819 | The SAL mechanism is complex and slow. A simpler mechanism is mapping all |
| 820 | characters to another character, mapping similar sounding characters to the |
| 821 | 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] | 822 | both SAL items and simple soundfolding. |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 823 | |
Bram Moolenaar | 7d1f5db | 2005-07-03 21:39:27 +0000 | [diff] [blame] | 824 | 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] | 825 | and one that specifies the characters they are mapped to. They must have |
| 826 | exactly the same number of characters. Example: |
| 827 | |
| 828 | SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ~ |
| 829 | SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkes ~ |
| 830 | |
| 831 | 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] | 832 | method would be to leave out all vowels. Some characters that sound nearly |
| 833 | the same and are often mixed up, such as 'm' and 'n', are mapped to the same |
| 834 | 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] | 835 | |
| 836 | Characters that do not appear in SOFOFROM will be left out, except that all |
| 837 | white space is replaced by one space. Sequences of the same character in |
| 838 | SOFOFROM are replaced by one. |
| 839 | |
| 840 | You can use the |soundfold()| function to try out the results. Or set the |
| 841 | 'verbose' option to see the score in the output of the |z?| command. |
| 842 | |
| 843 | |
Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 844 | vim:tw=78:sw=4:ts=8:ft=help:norl: |