Bram Moolenaar | 217ad92 | 2005-03-20 22:37:15 +0000 | [diff] [blame] | 1 | *spell.txt* For Vim version 7.0aa. Last change: 2005 Mar 20 |
| 2 | |
| 3 | |
| 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
| 5 | |
| 6 | |
| 7 | Spell checking *spell* |
| 8 | |
| 9 | 1. Quick start |spell-quickstart| |
| 10 | X. Spell file format |spell-file-format| |
| 11 | |
| 12 | {Vi does not have any of these commands} |
| 13 | |
| 14 | Spell checking is not available when the |+syntax| feature has been disabled |
| 15 | at compile time. |
| 16 | |
| 17 | ============================================================================== |
| 18 | 1. Quick start *spell-quickstart* |
| 19 | |
| 20 | This command switches on spell checking: > |
| 21 | |
| 22 | :setlocal spell spelllang=en_us |
| 23 | |
| 24 | This switches the 'spell' option on and specifies to check for US English. |
| 25 | |
| 26 | The words that are not recognized are highlighted with one of these: |
| 27 | SpellBad word not recognized |
| 28 | SpellRare rare word |
| 29 | SpellLocal wrong spelling for selected region |
| 30 | |
| 31 | |
| 32 | REGIONS |
| 33 | |
| 34 | A word may be spelled differently in various regions. For example, English |
| 35 | comes in (at least) these variants: |
| 36 | |
| 37 | en all regions |
| 38 | en_us US |
| 39 | en_gb Great Britain |
| 40 | en_ca Canada |
| 41 | |
| 42 | Words that are not used in one region but are used in another region are |
| 43 | highlighted with SpellLocal. |
| 44 | |
| 45 | Always use lowercase letters. |
| 46 | |
| 47 | |
| 48 | SPELL FILES |
| 49 | |
| 50 | Vim searches for spell files in the "spell" subdirectory of the directories in |
| 51 | 'runtimepath'. The name is: xx.yyy.spl, where: |
| 52 | xx the language name |
| 53 | yyy the value of 'encoding' |
| 54 | |
| 55 | Exception: Vim uses "latin1" when 'encoding' is "iso-8859-15". The euro sign |
| 56 | doesn't matter for spelling. |
| 57 | |
| 58 | A spell file might not be available in the current 'encoding'. You may try |
| 59 | using the "iconv" program to create one: > |
| 60 | |
| 61 | iconv -f latin1 -t koi8-r de.latin1.spl >de.koi8-r.spl |
| 62 | |
| 63 | However, if some characters cannot be presented in the target encoding this |
| 64 | will give wrong results. |
| 65 | |
| 66 | If a spell file only uses ASCII characters the encoding can be omitted. This |
| 67 | is useful for English: "en.spl" The file with encoding is checked first, thus |
| 68 | you could have one with encoding that includes words with non-ASCII characters |
| 69 | and use the ASCII file as a fall-back. |
| 70 | |
| 71 | ============================================================================== |
| 72 | X. Spell file format *spell-file-format* |
| 73 | *E751* |
| 74 | |
| 75 | The spelling for a language is specified in file with a specific format. |
| 76 | The first character of a line specifies what follows in the line: |
| 77 | |
| 78 | char argument meaning ~ |
| 79 | - xx words for xx region follow (repeats) |
| 80 | <space> <word> normal word |
| 81 | > <word> rare word |
| 82 | = <word> word with non-keyword characters |
| 83 | + <word> optional word addition |
| 84 | # <anything> comment |
| 85 | |
| 86 | Empty lines are ignored. The word continues until the end of the line. Watch |
| 87 | out for trailing white space! |
| 88 | |
| 89 | Words that start with an upper-case letter will be required to be written that |
| 90 | way. Otherwise, words must be in lower-case. |
| 91 | |
| 92 | It is possible that a word appears both with an upper-case letter and as a |
| 93 | rare word. This means that the word with an upper-case letter is OK and the |
| 94 | word without the upper-case letter is rare. |
| 95 | *E753* |
| 96 | The region is specified with "-xx". For example, in the "en.spl" file "-us" |
| 97 | starts the word for "en_us". This can be repeated for words that are used in |
| 98 | more than one region. For example "-ca-us" is used for Canadian and US |
| 99 | English words. Use "---" to go back to the words for all regions. |
| 100 | |
| 101 | Vim supports up to six regions. *E752* |
| 102 | |
| 103 | It is possible to have a match that starts with a valid word. In that case |
| 104 | the match is used, because it is longer. Example: |
| 105 | |
| 106 | we |
| 107 | =we're |
| 108 | |
| 109 | "re" is not a word, thus "=we're" is needed to avoid it gets highlighted. |
| 110 | |
| 111 | The "+" items may appear after any word. For English "'s" is used. Be |
| 112 | careful with this, it may hide mistakes. |
| 113 | |
| 114 | Vim will check for duplicate words in the files used, but you will only get |
| 115 | warnings if the 'verbose' option is set to 1 or more. |
| 116 | |
| 117 | Note that the "=" and "+" words will slow down the operation. Use them only |
| 118 | when really needed. |
| 119 | |
| 120 | |
| 121 | vim:tw=78:sw=4:ts=8:ft=help:norl: |