Bram Moolenaar | fff2bee | 2010-05-15 13:56:02 +0200 | [diff] [blame] | 1 | *mbyte.txt* For Vim version 7.3a. Last change: 2009 Nov 17 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2 | |
| 3 | |
| 4 | VIM REFERENCE MANUAL by Bram Moolenaar et al. |
| 5 | |
| 6 | |
| 7 | Multi-byte support *multibyte* *multi-byte* |
| 8 | *Chinese* *Japanese* *Korean* |
| 9 | This is about editing text in languages which have many characters that can |
| 10 | not be represented using one byte (one octet). Examples are Chinese, Japanese |
| 11 | and Korean. Unicode is also covered here. |
| 12 | |
| 13 | For an introduction to the most common features, see |usr_45.txt| in the user |
| 14 | manual. |
| 15 | For changing the language of messages and menus see |mlang.txt|. |
| 16 | |
| 17 | {not available when compiled without the +multi_byte feature} |
| 18 | |
| 19 | |
| 20 | 1. Getting started |mbyte-first| |
| 21 | 2. Locale |mbyte-locale| |
| 22 | 3. Encoding |mbyte-encoding| |
| 23 | 4. Using a terminal |mbyte-terminal| |
| 24 | 5. Fonts on X11 |mbyte-fonts-X11| |
| 25 | 6. Fonts on MS-Windows |mbyte-fonts-MSwin| |
| 26 | 7. Input on X11 |mbyte-XIM| |
| 27 | 8. Input on MS-Windows |mbyte-IME| |
| 28 | 9. Input with a keymap |mbyte-keymap| |
| 29 | 10. Using UTF-8 |mbyte-utf8| |
| 30 | 11. Overview of options |mbyte-options| |
| 31 | |
| 32 | NOTE: This file contains UTF-8 characters. These may show up as strange |
| 33 | characters or boxes when using another encoding. |
| 34 | |
| 35 | ============================================================================== |
| 36 | 1. Getting started *mbyte-first* |
| 37 | |
| 38 | This is a summary of the multibyte features in Vim. If you are lucky it works |
| 39 | as described and you can start using Vim without much trouble. If something |
| 40 | doesn't work you will have to read the rest. Don't be surprised if it takes |
| 41 | quite a bit of work and experimenting to make Vim use all the multi-byte |
| 42 | features. Unfortunately, every system has its own way to deal with multibyte |
| 43 | languages and it is quite complicated. |
| 44 | |
| 45 | |
| 46 | COMPILING |
| 47 | |
| 48 | If you already have a compiled Vim program, check if the |+multi_byte| feature |
| 49 | is included. The |:version| command can be used for this. |
| 50 | |
| 51 | If +multi_byte is not included, you should compile Vim with "big" features. |
| 52 | You can further tune what features are included. See the INSTALL files in the |
| 53 | source directory. |
| 54 | |
| 55 | |
| 56 | LOCALE |
| 57 | |
| 58 | First of all, you must make sure your current locale is set correctly. If |
| 59 | your system has been installed to use the language, it probably works right |
| 60 | away. If not, you can often make it work by setting the $LANG environment |
| 61 | variable in your shell: > |
| 62 | |
| 63 | setenv LANG ja_JP.EUC |
| 64 | |
| 65 | Unfortunately, the name of the locale depends on your system. Japanese might |
| 66 | also be called "ja_JP.EUCjp" or just "ja". To see what is currently used: > |
| 67 | |
| 68 | :language |
| 69 | |
| 70 | To change the locale inside Vim use: > |
| 71 | |
| 72 | :language ja_JP.EUC |
| 73 | |
| 74 | Vim will give an error message if this doesn't work. This is a good way to |
| 75 | experiment and find the locale name you want to use. But it's always better |
| 76 | to set the locale in the shell, so that it is used right from the start. |
| 77 | |
| 78 | See |mbyte-locale| for details. |
| 79 | |
| 80 | |
| 81 | ENCODING |
| 82 | |
| 83 | If your locale works properly, Vim will try to set the 'encoding' option |
| 84 | accordingly. If this doesn't work you can overrule its value: > |
| 85 | |
| 86 | :set encoding=utf-8 |
| 87 | |
| 88 | See |encoding-values| for a list of acceptable values. |
| 89 | |
| 90 | The result is that all the text that is used inside Vim will be in this |
| 91 | encoding. Not only the text in the buffers, but also in registers, variables, |
| 92 | etc. This also means that changing the value of 'encoding' makes the existing |
| 93 | text invalid! The text doesn't change, but it will be displayed wrong. |
| 94 | |
| 95 | You can edit files in another encoding than what 'encoding' is set to. Vim |
| 96 | will convert the file when you read it and convert it back when you write it. |
| 97 | See 'fileencoding', 'fileencodings' and |++enc|. |
| 98 | |
| 99 | |
| 100 | DISPLAY AND FONTS |
| 101 | |
| 102 | If you are working in a terminal (emulator) you must make sure it accepts the |
| 103 | same encoding as which Vim is working with. If this is not the case, you can |
| 104 | use the 'termencoding' option to make Vim convert text automatically. |
| 105 | |
| 106 | For the GUI you must select fonts that work with the current 'encoding'. This |
| 107 | is the difficult part. It depends on the system you are using, the locale and |
| 108 | a few other things. See the chapters on fonts: |mbyte-fonts-X11| for |
| 109 | X-Windows and |mbyte-fonts-MSwin| for MS-Windows. |
| 110 | |
| 111 | For GTK+ 2, you can skip most of this section. The option 'guifontset' does |
| 112 | no longer exist. You only need to set 'guifont' and everything should "just |
| 113 | work". If your system comes with Xft2 and fontconfig and the current font |
| 114 | does not contain a certain glyph, a different font will be used automatically |
| 115 | if available. The 'guifontwide' option is still supported but usually you do |
| 116 | not need to set it. It is only necessary if the automatic font selection does |
| 117 | not suit your needs. |
| 118 | |
| 119 | For X11 you can set the 'guifontset' option to a list of fonts that together |
| 120 | cover the characters that are used. Example for Korean: > |
| 121 | |
| 122 | :set guifontset=k12,r12 |
| 123 | |
| 124 | Alternatively, you can set 'guifont' and 'guifontwide'. 'guifont' is used for |
| 125 | the single-width characters, 'guifontwide' for the double-width characters. |
| 126 | Thus the 'guifontwide' font must be exactly twice as wide as 'guifont'. |
| 127 | Example for UTF-8: > |
| 128 | |
| 129 | :set guifont=-misc-fixed-medium-r-normal-*-18-120-100-100-c-90-iso10646-1 |
| 130 | :set guifontwide=-misc-fixed-medium-r-normal-*-18-120-100-100-c-180-iso10646-1 |
| 131 | |
| 132 | You can also set 'guifont' alone, Vim will try to find a matching |
| 133 | 'guifontwide' for you. |
| 134 | |
| 135 | |
| 136 | INPUT |
| 137 | |
| 138 | There are several ways to enter multi-byte characters: |
| 139 | - For X11 XIM can be used. See |XIM|. |
| 140 | - For MS-Windows IME can be used. See |IME|. |
| 141 | - For all systems keymaps can be used. See |mbyte-keymap|. |
| 142 | |
| 143 | The options 'iminsert', 'imsearch' and 'imcmdline' can be used to chose |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 144 | the different input methods or disable them temporarily. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 145 | |
| 146 | ============================================================================== |
| 147 | 2. Locale *mbyte-locale* |
| 148 | |
| 149 | The easiest setup is when your whole system uses the locale you want to work |
| 150 | in. But it's also possible to set the locale for one shell you are working |
| 151 | in, or just use a certain locale inside Vim. |
| 152 | |
| 153 | |
| 154 | WHAT IS A LOCALE? *locale* |
| 155 | |
| 156 | There are many of languages in the world. And there are different cultures |
| 157 | and environments at least as much as the number of languages. A linguistic |
| 158 | environment corresponding to an area is called "locale". This includes |
| 159 | information about the used language, the charset, collating order for sorting, |
| 160 | date format, currency format and so on. For Vim only the language and charset |
| 161 | really matter. |
| 162 | |
| 163 | You can only use a locale if your system has support for it. Some systems |
| 164 | have only a few locales, especially in the USA. The language which you want |
| 165 | to use may not be on your system. In that case you might be able to install |
| 166 | it as an extra package. Check your system documentation for how to do that. |
| 167 | |
| 168 | The location in which the locales are installed varies from system to system. |
| 169 | For example, "/usr/share/locale" or "/usr/lib/locale". See your system's |
| 170 | setlocale() man page. |
| 171 | |
| 172 | Looking in these directories will show you the exact name of each locale. |
| 173 | Mostly upper/lowercase matters, thus "ja_JP.EUC" and "ja_jp.euc" are |
| 174 | different. Some systems have a locale.alias file, which allows translation |
| 175 | from a short name like "nl" to the full name "nl_NL.ISO_8859-1". |
| 176 | |
| 177 | Note that X-windows has its own locale stuff. And unfortunately uses locale |
| 178 | names different from what is used elsewhere. This is confusing! For Vim it |
| 179 | matters what the setlocale() function uses, which is generally NOT the |
| 180 | X-windows stuff. You might have to do some experiments to find out what |
| 181 | really works. |
| 182 | |
| 183 | *locale-name* |
| 184 | The (simplified) format of |locale| name is: |
| 185 | |
| 186 | language |
| 187 | or language_territory |
| 188 | or language_territory.codeset |
| 189 | |
| 190 | Territory means the country (or part of it), codeset means the |charset|. For |
| 191 | example, the locale name "ja_JP.eucJP" means: |
| 192 | ja the language is Japanese |
| 193 | JP the country is Japan |
| 194 | eucJP the codeset is EUC-JP |
| 195 | But it also could be "ja", "ja_JP.EUC", "ja_JP.ujis", etc. And unfortunately, |
| 196 | the locale name for a specific language, territory and codeset is not unified |
| 197 | and depends on your system. |
| 198 | |
| 199 | Examples of locale name: |
| 200 | charset language locale name ~ |
| 201 | GB2312 Chinese (simplified) zh_CN.EUC, zh_CN.GB2312 |
| 202 | Big5 Chinese (traditional) zh_TW.BIG5, zh_TW.Big5 |
| 203 | CNS-11643 Chinese (traditional) zh_TW |
| 204 | EUC-JP Japanese ja, ja_JP.EUC, ja_JP.ujis, ja_JP.eucJP |
| 205 | Shift_JIS Japanese ja_JP.SJIS, ja_JP.Shift_JIS |
| 206 | EUC-KR Korean ko, ko_KR.EUC |
| 207 | |
| 208 | |
| 209 | USING A LOCALE |
| 210 | |
| 211 | To start using a locale for the whole system, see the documentation of your |
| 212 | system. Mostly you need to set it in a configuration file in "/etc". |
| 213 | |
| 214 | To use a locale in a shell, set the $LANG environment value. When you want to |
| 215 | use Korean and the |locale| name is "ko", do this: |
| 216 | |
| 217 | sh: export LANG=ko |
| 218 | csh: setenv LANG ko |
| 219 | |
| 220 | You can put this in your ~/.profile or ~/.cshrc file to always use it. |
| 221 | |
| 222 | To use a locale in Vim only, use the |:language| command: > |
| 223 | |
| 224 | :language ko |
| 225 | |
| 226 | Put this in your ~/.vimrc file to use it always. |
| 227 | |
| 228 | Or specify $LANG when starting Vim: |
| 229 | |
| 230 | sh: LANG=ko vim {vim-arguments} |
| 231 | csh: env LANG=ko vim {vim-arguments} |
| 232 | |
| 233 | You could make a small shell script for this. |
| 234 | |
| 235 | ============================================================================== |
| 236 | 3. Encoding *mbyte-encoding* |
| 237 | |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 238 | Vim uses the 'encoding' option to specify how characters are identified and |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 239 | encoded when they are used inside Vim. This applies to all the places where |
| 240 | text is used, including buffers (files loaded into memory), registers and |
| 241 | variables. |
| 242 | |
| 243 | *charset* *codeset* |
| 244 | Charset is another name for encoding. There are subtle differences, but these |
| 245 | don't matter when using Vim. "codeset" is another similar name. |
| 246 | |
| 247 | Each character is encoded as one or more bytes. When all characters are |
| 248 | encoded with one byte, we call this a single-byte encoding. The most often |
| 249 | used one is called "latin1". This limits the number of characters to 256. |
| 250 | Some of these are control characters, thus even fewer can be used for text. |
| 251 | |
| 252 | When some characters use two or more bytes, we call this a multi-byte |
| 253 | encoding. This allows using much more than 256 characters, which is required |
| 254 | for most East Asian languages. |
| 255 | |
| 256 | Most multi-byte encodings use one byte for the first 127 characters. These |
| 257 | are equal to ASCII, which makes it easy to exchange plain-ASCII text, no |
| 258 | matter what language is used. Thus you might see the right text even when the |
| 259 | encoding was set wrong. |
| 260 | |
| 261 | *encoding-names* |
| 262 | Vim can use many different character encodings. There are three major groups: |
| 263 | |
| 264 | 1 8bit Single-byte encodings, 256 different characters. Mostly used |
| 265 | in USA and Europe. Example: ISO-8859-1 (Latin1). All |
| 266 | characters occupy one screen cell only. |
| 267 | |
| 268 | 2 2byte Double-byte encodings, over 10000 different characters. |
| 269 | Mostly used in Asian countries. Example: euc-kr (Korean) |
| 270 | The number of screen cells is equal to the number of bytes |
| 271 | (except for euc-jp when the first byte is 0x8e). |
| 272 | |
| 273 | u Unicode Universal encoding, can replace all others. ISO 10646. |
| 274 | Millions of different characters. Example: UTF-8. The |
| 275 | relation between bytes and screen cells is complex. |
| 276 | |
| 277 | Other encodings cannot be used by Vim internally. But files in other |
| 278 | encodings can be edited by using conversion, see 'fileencoding'. |
| 279 | Note that all encodings must use ASCII for the characters up to 128 (except |
| 280 | when compiled for EBCDIC). |
| 281 | |
| 282 | Supported 'encoding' values are: *encoding-values* |
| 283 | 1 latin1 8-bit characters (ISO 8859-1) |
| 284 | 1 iso-8859-n ISO_8859 variant (n = 2 to 15) |
| 285 | 1 koi8-r Russian |
| 286 | 1 koi8-u Ukrainian |
| 287 | 1 macroman MacRoman (Macintosh encoding) |
| 288 | 1 8bit-{name} any 8-bit encoding (Vim specific name) |
Bram Moolenaar | 35fdbb5 | 2005-07-09 21:08:57 +0000 | [diff] [blame] | 289 | 1 cp437 similar to iso-8859-1 |
| 290 | 1 cp737 similar to iso-8859-7 |
| 291 | 1 cp775 Baltic |
| 292 | 1 cp850 similar to iso-8859-4 |
| 293 | 1 cp852 similar to iso-8859-1 |
| 294 | 1 cp855 similar to iso-8859-2 |
| 295 | 1 cp857 similar to iso-8859-5 |
| 296 | 1 cp860 similar to iso-8859-9 |
| 297 | 1 cp861 similar to iso-8859-1 |
| 298 | 1 cp862 similar to iso-8859-1 |
| 299 | 1 cp863 similar to iso-8859-8 |
| 300 | 1 cp865 similar to iso-8859-1 |
| 301 | 1 cp866 similar to iso-8859-5 |
| 302 | 1 cp869 similar to iso-8859-7 |
| 303 | 1 cp874 Thai |
| 304 | 1 cp1250 Czech, Polish, etc. |
| 305 | 1 cp1251 Cyrillic |
| 306 | 1 cp1253 Greek |
| 307 | 1 cp1254 Turkish |
| 308 | 1 cp1255 Hebrew |
| 309 | 1 cp1256 Arabic |
| 310 | 1 cp1257 Baltic |
| 311 | 1 cp1258 Vietnamese |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 312 | 1 cp{number} MS-Windows: any installed single-byte codepage |
| 313 | 2 cp932 Japanese (Windows only) |
| 314 | 2 euc-jp Japanese (Unix only) |
| 315 | 2 sjis Japanese (Unix only) |
| 316 | 2 cp949 Korean (Unix and Windows) |
| 317 | 2 euc-kr Korean (Unix only) |
| 318 | 2 cp936 simplified Chinese (Windows only) |
| 319 | 2 euc-cn simplified Chinese (Unix only) |
| 320 | 2 cp950 traditional Chinese (on Unix alias for big5) |
| 321 | 2 big5 traditional Chinese (on Windows alias for cp950) |
| 322 | 2 euc-tw traditional Chinese (Unix only) |
| 323 | 2 2byte-{name} Unix: any double-byte encoding (Vim specific name) |
| 324 | 2 cp{number} MS-Windows: any installed double-byte codepage |
| 325 | u utf-8 32 bit UTF-8 encoded Unicode (ISO/IEC 10646-1) |
| 326 | u ucs-2 16 bit UCS-2 encoded Unicode (ISO/IEC 10646-1) |
| 327 | u ucs-2le like ucs-2, little endian |
| 328 | u utf-16 ucs-2 extended with double-words for more characters |
| 329 | u utf-16le like utf-16, little endian |
| 330 | u ucs-4 32 bit UCS-4 encoded Unicode (ISO/IEC 10646-1) |
| 331 | u ucs-4le like ucs-4, little endian |
| 332 | |
| 333 | The {name} can be any encoding name that your system supports. It is passed |
| 334 | to iconv() to convert between the encoding of the file and the current locale. |
| 335 | For MS-Windows "cp{number}" means using codepage {number}. |
| 336 | Examples: > |
| 337 | :set encoding=8bit-cp1252 |
| 338 | :set encoding=2byte-cp932 |
| 339 | < |
| 340 | Several aliases can be used, they are translated to one of the names above. |
| 341 | An incomplete list: |
| 342 | |
| 343 | 1 ansi same as latin1 (obsolete, for backward compatibility) |
| 344 | 2 japan Japanese: on Unix "euc-jp", on MS-Windows cp932 |
| 345 | 2 korea Korean: on Unix "euc-kr", on MS-Windows cp949 |
| 346 | 2 prc simplified Chinese: on Unix "euc-cn", on MS-Windows cp936 |
| 347 | 2 chinese same as "prc" |
| 348 | 2 taiwan traditional Chinese: on Unix "euc-tw", on MS-Windows cp950 |
| 349 | u utf8 same as utf-8 |
| 350 | u unicode same as ucs-2 |
| 351 | u ucs2be same as ucs-2 (big endian) |
| 352 | u ucs-2be same as ucs-2 (big endian) |
| 353 | u ucs-4be same as ucs-4 (big endian) |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 354 | u utf-32 same as ucs-4 |
| 355 | u utf-32le same as ucs-4le |
Bram Moolenaar | 1cd871b | 2004-12-19 22:46:22 +0000 | [diff] [blame] | 356 | default stands for the default value of 'encoding', depends on the |
Bram Moolenaar | c9b4b05 | 2006-04-30 18:54:39 +0000 | [diff] [blame] | 357 | environment |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 358 | |
| 359 | For the UCS codes the byte order matters. This is tricky, use UTF-8 whenever |
| 360 | you can. The default is to use big-endian (most significant byte comes |
| 361 | first): |
| 362 | name bytes char ~ |
| 363 | ucs-2 11 22 1122 |
| 364 | ucs-2le 22 11 1122 |
| 365 | ucs-4 11 22 33 44 11223344 |
| 366 | ucs-4le 44 33 22 11 11223344 |
| 367 | |
| 368 | On MS-Windows systems you often want to use "ucs-2le", because it uses little |
| 369 | endian UCS-2. |
| 370 | |
| 371 | There are a few encodings which are similar, but not exactly the same. Vim |
| 372 | treats them as if they were different encodings, so that conversion will be |
| 373 | done when needed. You might want to use the similar name to avoid conversion |
| 374 | or when conversion is not possible: |
| 375 | |
| 376 | cp932, shift-jis, sjis |
| 377 | cp936, euc-cn |
| 378 | |
| 379 | *encoding-table* |
| 380 | Normally 'encoding' is equal to your current locale and 'termencoding' is |
| 381 | empty. This means that your keyboard and display work with characters encoded |
| 382 | in your current locale, and Vim uses the same characters internally. |
| 383 | |
| 384 | You can make Vim use characters in a different encoding by setting the |
| 385 | 'encoding' option to a different value. Since the keyboard and display still |
| 386 | use the current locale, conversion needs to be done. The 'termencoding' then |
| 387 | takes over the value of the current locale, so Vim converts between 'encoding' |
| 388 | and 'termencoding'. Example: > |
| 389 | :let &termencoding = &encoding |
| 390 | :set encoding=utf-8 |
| 391 | |
| 392 | However, not all combinations of values are possible. The table below tells |
| 393 | you how each of the nine combinations works. This is further restricted by |
| 394 | not all conversions being possible, iconv() being present, etc. Since this |
| 395 | depends on the system used, no detailed list can be given. |
| 396 | |
| 397 | ('tenc' is the short name for 'termencoding' and 'enc' short for 'encoding') |
| 398 | |
| 399 | 'tenc' 'enc' remark ~ |
| 400 | |
| 401 | 8bit 8bit Works. When 'termencoding' is different from |
| 402 | 'encoding' typing and displaying may be wrong for some |
| 403 | characters, Vim does NOT perform conversion (set |
| 404 | 'encoding' to "utf-8" to get this). |
| 405 | 8bit 2byte MS-Windows: works for all codepages installed on your |
| 406 | system; you can only type 8bit characters; |
| 407 | Other systems: does NOT work. |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 408 | 8bit Unicode Works, but only 8bit characters can be typed directly |
| 409 | (others through digraphs, keymaps, etc.); in a |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 410 | terminal you can only see 8bit characters; the GUI can |
| 411 | show all characters that the 'guifont' supports. |
| 412 | |
| 413 | 2byte 8bit Works, but typing non-ASCII characters might |
| 414 | be a problem. |
| 415 | 2byte 2byte MS-Windows: works for all codepages installed on your |
| 416 | system; typing characters might be a problem when |
| 417 | locale is different from 'encoding'. |
| 418 | Other systems: Only works when 'termencoding' is equal |
| 419 | to 'encoding', you might as well leave it empty. |
| 420 | 2byte Unicode works, Vim will translate typed characters. |
| 421 | |
| 422 | Unicode 8bit works (unusual) |
| 423 | Unicode 2byte does NOT work |
| 424 | Unicode Unicode works very well (leaving 'termencoding' empty works |
| 425 | the same way, because all Unicode is handled |
| 426 | internally as UTF-8) |
| 427 | |
| 428 | CONVERSION *charset-conversion* |
| 429 | |
| 430 | Vim will automatically convert from one to another encoding in several places: |
| 431 | - When reading a file and 'fileencoding' is different from 'encoding' |
| 432 | - When writing a file and 'fileencoding' is different from 'encoding' |
| 433 | - When displaying characters and 'termencoding' is different from 'encoding' |
| 434 | - When reading input and 'termencoding' is different from 'encoding' |
| 435 | - When displaying messages and the encoding used for LC_MESSAGES differs from |
| 436 | 'encoding' (requires a gettext version that supports this). |
| 437 | - When reading a Vim script where |:scriptencoding| is different from |
| 438 | 'encoding'. |
| 439 | - When reading or writing a |viminfo| file. |
| 440 | Most of these require the |+iconv| feature. Conversion for reading and |
| 441 | writing files may also be specified with the 'charconvert' option. |
| 442 | |
| 443 | Useful utilities for converting the charset: |
| 444 | All: iconv |
| 445 | GNU iconv can convert most encodings. Unicode is used as the |
| 446 | intermediate encoding, which allows conversion from and to all other |
| 447 | encodings. See http://www.gnu.org/directory/libiconv.html. |
| 448 | |
| 449 | Japanese: nkf |
| 450 | Nkf is "Network Kanji code conversion Filter". One of the most unique |
| 451 | facility of nkf is the guess of the input Kanji code. So, you don't |
| 452 | need to know what the inputting file's |charset| is. When convert to |
| 453 | EUC-JP from ISO-2022-JP or Shift_JIS, simply do the following command |
| 454 | in Vim: |
| 455 | :%!nkf -e |
| 456 | Nkf can be found at: |
| 457 | http://www.sfc.wide.ad.jp/~max/FreeBSD/ports/distfiles/nkf-1.62.tar.gz |
| 458 | |
| 459 | Chinese: hc |
| 460 | Hc is "Hanzi Converter". Hc convert a GB file to a Big5 file, or Big5 |
| 461 | file to GB file. Hc can be found at: |
| 462 | ftp://ftp.cuhk.hk/pub/chinese/ifcss/software/unix/convert/hc-30.tar.gz |
| 463 | |
| 464 | Korean: hmconv |
Bram Moolenaar | 402d2fe | 2005-04-15 21:00:38 +0000 | [diff] [blame] | 465 | Hmconv is Korean code conversion utility especially for E-mail. It can |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 466 | convert between EUC-KR and ISO-2022-KR. Hmconv can be found at: |
| 467 | ftp://ftp.kaist.ac.kr/pub/hangul/code/hmconv/ |
| 468 | |
| 469 | Multilingual: lv |
| 470 | Lv is a Powerful Multilingual File Viewer. And it can be worked as |
| 471 | |charset| converter. Supported |charset|: ISO-2022-CN, ISO-2022-JP, |
| 472 | ISO-2022-KR, EUC-CN, EUC-JP, EUC-KR, EUC-TW, UTF-7, UTF-8, ISO-8859 |
Bram Moolenaar | 402d2fe | 2005-04-15 21:00:38 +0000 | [diff] [blame] | 473 | series, Shift_JIS, Big5 and HZ. Lv can be found at: |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 474 | http://www.ff.iij4u.or.jp/~nrt/freeware/lv4495.tar.gz |
| 475 | |
| 476 | |
| 477 | *mbyte-conversion* |
| 478 | When reading and writing files in an encoding different from 'encoding', |
| 479 | conversion needs to be done. These conversions are supported: |
| 480 | - All conversions between Latin-1 (ISO-8859-1), UTF-8, UCS-2 and UCS-4 are |
| 481 | handled internally. |
| 482 | - For MS-Windows, when 'encoding' is a Unicode encoding, conversion from and |
| 483 | to any codepage should work. |
| 484 | - Conversion specified with 'charconvert' |
| 485 | - Conversion with the iconv library, if it is available. |
| 486 | Old versions of GNU iconv() may cause the conversion to fail (they |
| 487 | request a very large buffer, more than Vim is willing to provide). |
| 488 | Try getting another iconv() implementation. |
| 489 | |
Bram Moolenaar | a5792f5 | 2005-11-23 21:25:05 +0000 | [diff] [blame] | 490 | *iconv-dynamic* |
| 491 | On MS-Windows Vim can be compiled with the |+iconv/dyn| feature. This means |
| 492 | Vim will search for the "iconv.dll" and "libiconv.dll" libraries. When |
| 493 | neither of them can be found Vim will still work but some conversions won't be |
| 494 | possible. |
| 495 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 496 | ============================================================================== |
| 497 | 4. Using a terminal *mbyte-terminal* |
| 498 | |
| 499 | The GUI fully supports multi-byte characters. It is also possible in a |
| 500 | terminal, if the terminal supports the same encoding that Vim uses. Thus this |
| 501 | is less flexible. |
| 502 | |
| 503 | For example, you can run Vim in a xterm with added multi-byte support and/or |
| 504 | |XIM|. Examples are kterm (Kanji term) and hanterm (for Korean), Eterm |
| 505 | (Enlightened terminal) and rxvt. |
| 506 | |
| 507 | If your terminal does not support the right encoding, you can set the |
| 508 | 'termencoding' option. Vim will then convert the typed characters from |
| 509 | 'termencoding' to 'encoding'. And displayed text will be converted from |
| 510 | 'encoding' to 'termencoding'. If the encoding supported by the terminal |
| 511 | doesn't include all the characters that Vim uses, this leads to lost |
| 512 | characters. This may mess up the display. If you use a terminal that |
| 513 | supports Unicode, such as the xterm mentioned below, it should work just fine, |
| 514 | since nearly every character set can be converted to Unicode without loss of |
| 515 | information. |
| 516 | |
| 517 | |
| 518 | UTF-8 IN XFREE86 XTERM *UTF8-xterm* |
| 519 | |
| 520 | This is a short explanation of how to use UTF-8 character encoding in the |
| 521 | xterm that comes with XFree86 by Thomas Dickey (text by Markus Kuhn). |
| 522 | |
| 523 | Get the latest xterm version which has now UTF-8 support: |
| 524 | |
| 525 | http://invisible-island.net/xterm/xterm.html |
| 526 | |
| 527 | Compile it with "./configure --enable-wide-chars ; make" |
| 528 | |
| 529 | Also get the ISO 10646-1 version of various fonts, which is available on |
| 530 | |
| 531 | http://www.cl.cam.ac.uk/~mgk25/download/ucs-fonts.tar.gz |
| 532 | |
| 533 | and install the font as described in the README file. |
| 534 | |
| 535 | Now start xterm with > |
| 536 | |
| 537 | xterm -u8 -fn -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1 |
| 538 | or, for bigger character: > |
| 539 | xterm -u8 -fn -misc-fixed-medium-r-normal--15-140-75-75-c-90-iso10646-1 |
| 540 | |
Bram Moolenaar | 402d2fe | 2005-04-15 21:00:38 +0000 | [diff] [blame] | 541 | and you will have a working UTF-8 terminal emulator. Try both > |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 542 | |
| 543 | cat utf-8-demo.txt |
| 544 | vim utf-8-demo.txt |
| 545 | |
| 546 | with the demo text that comes with ucs-fonts.tar.gz in order to see |
| 547 | whether there are any problems with UTF-8 in your xterm. |
| 548 | |
| 549 | For Vim you may need to set 'encoding' to "utf-8". |
| 550 | |
| 551 | ============================================================================== |
| 552 | 5. Fonts on X11 *mbyte-fonts-X11* |
| 553 | |
| 554 | Unfortunately, using fonts in X11 is complicated. The name of a single-byte |
| 555 | font is a long string. For multi-byte fonts we need several of these... |
| 556 | |
| 557 | Note: Most of this is no longer relevant for GTK+ 2. Selecting a font via |
Bram Moolenaar | 8f3f58f | 2010-01-06 20:52:26 +0100 | [diff] [blame] | 558 | its XLFD is not supported; see 'guifont' for an example of how to |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 559 | set the font. Do yourself a favor and ignore the |XLFD| and |xfontset| |
| 560 | sections below. |
| 561 | |
| 562 | First of all, Vim only accepts fixed-width fonts for displaying text. You |
| 563 | cannot use proportionally spaced fonts. This excludes many of the available |
| 564 | (and nicer looking) fonts. However, for menus and tooltips any font can be |
| 565 | used. |
| 566 | |
| 567 | Note that Display and Input are independent. It is possible to see your |
| 568 | language even though you have no input method for it. |
| 569 | |
| 570 | You should get a default font for menus and tooltips that works, but it might |
| 571 | be ugly. Read the following to find out how to select a better font. |
| 572 | |
| 573 | |
| 574 | X LOGICAL FONT DESCRIPTION (XLFD) |
| 575 | *XLFD* |
| 576 | XLFD is the X font name and contains the information about the font size, |
| 577 | charset, etc. The name is in this format: |
| 578 | |
| 579 | FOUNDRY-FAMILY-WEIGHT-SLANT-WIDTH-STYLE-PIXEL-POINT-X-Y-SPACE-AVE-CR-CE |
| 580 | |
| 581 | Each field means: |
| 582 | |
| 583 | - FOUNDRY: FOUNDRY field. The company that created the font. |
| 584 | - FAMILY: FAMILY_NAME field. Basic font family name. (helvetica, gothic, |
| 585 | times, etc) |
| 586 | - WEIGHT: WEIGHT_NAME field. How thick the letters are. (light, medium, |
| 587 | bold, etc) |
| 588 | - SLANT: SLANT field. |
| 589 | r: Roman (no slant) |
| 590 | i: Italic |
| 591 | o: Oblique |
| 592 | ri: Reverse Italic |
| 593 | ro: Reverse Oblique |
| 594 | ot: Other |
| 595 | number: Scaled font |
| 596 | - WIDTH: SETWIDTH_NAME field. Width of characters. (normal, condensed, |
| 597 | narrow, double wide) |
| 598 | - STYLE: ADD_STYLE_NAME field. Extra info to describe font. (Serif, Sans |
| 599 | Serif, Informal, Decorated, etc) |
| 600 | - PIXEL: PIXEL_SIZE field. Height, in pixels, of characters. |
| 601 | - POINT: POINT_SIZE field. Ten times height of characters in points. |
| 602 | - X: RESOLUTION_X field. X resolution (dots per inch). |
| 603 | - Y: RESOLUTION_Y field. Y resolution (dots per inch). |
| 604 | - SPACE: SPACING field. |
| 605 | p: Proportional |
| 606 | m: Monospaced |
| 607 | c: CharCell |
| 608 | - AVE: AVERAGE_WIDTH field. Ten times average width in pixels. |
| 609 | - CR: CHARSET_REGISTRY field. The name of the charset group. |
| 610 | - CE: CHARSET_ENCODING field. The rest of the charset name. For some |
| 611 | charsets, such as JIS X 0208, if this field is 0, code points has |
| 612 | the same value as GL, and GR if 1. |
| 613 | |
| 614 | For example, in case of a 14 dots font corresponding to JIS X 0208, it is |
| 615 | written like: |
| 616 | -misc-fixed-medium-r-normal--16-110-100-100-c-160-jisx0208.1990-0 |
| 617 | |
| 618 | |
| 619 | X FONTSET |
| 620 | *fontset* *xfontset* |
| 621 | A single-byte charset is typically associated with one font. For multi-byte |
| 622 | charsets a combination of fonts is often used. This means that one group of |
| 623 | characters are used from one font and another group from another font (which |
| 624 | might be double wide). This collection of fonts is called a fontset. |
| 625 | |
| 626 | Which fonts are required in a fontset depends on the current locale. X |
| 627 | windows maintains a table of which groups of characters are required for a |
| 628 | locale. You have to specify all the fonts that a locale requires in the |
| 629 | 'guifontset' option. |
| 630 | |
| 631 | NOTE: The fontset always uses the current locale, even though 'encoding' may |
| 632 | be set to use a different charset. In that situation you might want to use |
| 633 | 'guifont' and 'guifontwide' instead of 'guifontset'. |
| 634 | |
| 635 | Example: |
| 636 | |charset| language "groups of characters" ~ |
| 637 | GB2312 Chinese (simplified) ISO-8859-1 and GB 2312 |
| 638 | Big5 Chinese (traditional) ISO-8859-1 and Big5 |
| 639 | CNS-11643 Chinese (traditional) ISO-8859-1, CNS 11643-1 and CNS 11643-2 |
| 640 | EUC-JP Japanese JIS X 0201 and JIS X 0208 |
| 641 | EUC-KR Korean ISO-8859-1 and KS C 5601 (KS X 1001) |
| 642 | |
| 643 | You can search for fonts using the xlsfonts command. For example, when you're |
| 644 | searching for a font for KS C 5601: > |
| 645 | xlsfonts | grep ksc5601 |
| 646 | |
| 647 | This is complicated and confusing. You might want to consult the X-Windows |
| 648 | documentation if there is something you don't understand. |
| 649 | |
| 650 | *base_font_name_list* |
| 651 | When you have found the names of the fonts you want to use, you need to set |
| 652 | the 'guifontset' option. You specify the list by concatenating the font names |
| 653 | and putting a comma in between them. |
| 654 | |
| 655 | For example, when you use the ja_JP.eucJP locale, this requires JIS X 0201 |
| 656 | and JIS X 0208. You could supply a list of fonts that explicitly specifies |
| 657 | the charsets, like: > |
| 658 | |
| 659 | :set guifontset=-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-0, |
| 660 | \-misc-fixed-medium-r-normal--14-130-75-75-c-70-jisx0201.1976-0 |
| 661 | |
| 662 | Alternatively, you can supply a base font name list that omits the charset |
| 663 | name, letting X-Windows select font characters required for the locale. For |
| 664 | example: > |
| 665 | |
| 666 | :set guifontset=-misc-fixed-medium-r-normal--14-130-75-75-c-140, |
| 667 | \-misc-fixed-medium-r-normal--14-130-75-75-c-70 |
| 668 | |
| 669 | Alternatively, you can supply a single base font name that allows X-Windows to |
| 670 | select from all available fonts. For example: > |
| 671 | |
| 672 | :set guifontset=-misc-fixed-medium-r-normal--14-* |
| 673 | |
| 674 | Alternatively, you can specify alias names. See the fonts.alias file in the |
| 675 | fonts directory (e.g., /usr/X11R6/lib/X11/fonts/). For example: > |
| 676 | |
| 677 | :set guifontset=k14,r14 |
| 678 | < |
| 679 | *E253* |
| 680 | Note that in East Asian fonts, the standard character cell is square. When |
| 681 | mixing a Latin font and an East Asian font, the East Asian font width should |
| 682 | be twice the Latin font width. |
| 683 | |
| 684 | If 'guifontset' is not empty, the "font" argument of the |:highlight| command |
| 685 | is also interpreted as a fontset. For example, you should use for |
| 686 | highlighting: > |
| 687 | :hi Comment font=english_font,your_font |
| 688 | If you use a wrong "font" argument you will get an error message. |
| 689 | Also make sure that you set 'guifontset' before setting fonts for highlight |
| 690 | groups. |
| 691 | |
| 692 | |
| 693 | USING RESOURCE FILES |
| 694 | |
| 695 | Instead of specifying 'guifontset', you can set X11 resources and Vim will |
| 696 | pick them up. This is only for people who know how X resource files work. |
| 697 | |
| 698 | For Motif and Athena insert these three lines in your $HOME/.Xdefaults file: |
| 699 | |
| 700 | Vim.font: |base_font_name_list| |
| 701 | Vim*fontSet: |base_font_name_list| |
| 702 | Vim*fontList: your_language_font |
| 703 | |
| 704 | Note: Vim.font is for text area. |
| 705 | Vim*fontSet is for menu. |
| 706 | Vim*fontList is for menu (for Motif GUI) |
| 707 | |
| 708 | For example, when you are using Japanese and a 14 dots font, > |
| 709 | |
| 710 | Vim.font: -misc-fixed-medium-r-normal--14-* |
| 711 | Vim*fontSet: -misc-fixed-medium-r-normal--14-* |
| 712 | Vim*fontList: -misc-fixed-medium-r-normal--14-* |
| 713 | < |
| 714 | or: > |
| 715 | |
| 716 | Vim*font: k14,r14 |
| 717 | Vim*fontSet: k14,r14 |
| 718 | Vim*fontList: k14,r14 |
| 719 | < |
| 720 | To have them take effect immediately you will have to do > |
| 721 | |
| 722 | xrdb -merge ~/.Xdefaults |
| 723 | |
| 724 | Otherwise you will have to stop and restart the X server before the changes |
| 725 | take effect. |
| 726 | |
| 727 | |
| 728 | The GTK+ version of GUI Vim does not use .Xdefaults, use ~/.gtkrc instead. |
| 729 | The default mostly works OK. But for the menus you might have to change |
| 730 | it. Example: > |
| 731 | |
| 732 | style "default" |
| 733 | { |
| 734 | fontset="-*-*-medium-r-normal--14-*-*-*-c-*-*-*" |
| 735 | } |
| 736 | widget_class "*" style "default" |
| 737 | |
| 738 | ============================================================================== |
| 739 | 6. Fonts on MS-Windows *mbyte-fonts-MSwin* |
| 740 | |
| 741 | The simplest is to use the font dialog to select fonts and try them out. You |
| 742 | can find this at the "Edit/Select Font..." menu. Once you find a font name |
| 743 | that works well you can use this command to see its name: > |
| 744 | |
| 745 | :set guifont |
| 746 | |
| 747 | Then add a command to your |gvimrc| file to set 'guifont': > |
| 748 | |
| 749 | :set guifont=courier_new:h12 |
| 750 | |
| 751 | ============================================================================== |
| 752 | 7. Input on X11 *mbyte-XIM* |
| 753 | |
| 754 | X INPUT METHOD (XIM) BACKGROUND *XIM* *xim* *x-input-method* |
| 755 | |
| 756 | XIM is an international input module for X. There are two kind of structures, |
| 757 | Xlib unit type and |IM-server| (Input-Method server) type. |IM-server| type |
| 758 | is suitable for complex input, such as CJK. |
| 759 | |
| 760 | - IM-server |
| 761 | *IM-server* |
| 762 | In |IM-server| type input structures, the input event is handled by either |
| 763 | of the two ways: FrontEnd system and BackEnd system. In the FrontEnd |
| 764 | system, input events are snatched by the |IM-server| first, then |IM-server| |
| 765 | give the application the result of input. On the other hand, the BackEnd |
| 766 | system works reverse order. MS Windows adopt BackEnd system. In X, most of |
| 767 | |IM-server|s adopt FrontEnd system. The demerit of BackEnd system is the |
| 768 | large overhead in communication, but it provides safe synchronization with |
| 769 | no restrictions on applications. |
| 770 | |
| 771 | For example, there are xwnmo and kinput2 Japanese |IM-server|, both are |
| 772 | FrontEnd system. Xwnmo is distributed with Wnn (see below), kinput2 can be |
| 773 | found at: ftp://ftp.sra.co.jp/pub/x11/kinput2/ |
| 774 | |
| 775 | For Chinese, there's a great XIM server named "xcin", you can input both |
| 776 | Traditional and Simplified Chinese characters. And it can accept other |
| 777 | locale if you make a correct input table. Xcin can be found at: |
| 778 | http://xcin.linux.org.tw/ |
Bram Moolenaar | 8299df9 | 2004-07-10 09:47:34 +0000 | [diff] [blame] | 779 | Others are scim: http://scim.freedesktop.org/ and fcitx: |
Bram Moolenaar | c9b4b05 | 2006-04-30 18:54:39 +0000 | [diff] [blame] | 780 | http://www.fcitx.org/ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 781 | |
| 782 | - Conversion Server |
| 783 | *conversion-server* |
| 784 | Some system needs additional server: conversion server. Most of Japanese |
| 785 | |IM-server|s need it, Kana-Kanji conversion server. For Chinese inputting, |
| 786 | it depends on the method of inputting, in some methods, PinYin or ZhuYin to |
| 787 | HanZi conversion server is needed. For Korean inputting, if you want to |
| 788 | input Hanja, Hangul-Hanja conversion server is needed. |
| 789 | |
| 790 | For example, the Japanese inputting process is divided into 2 steps. First |
| 791 | we pre-input Hira-gana, second Kana-Kanji conversion. There are so many |
| 792 | Kanji characters (6349 Kanji characters are defined in JIS X 0208) and the |
| 793 | number of Hira-gana characters are 76. So, first, we pre-input text as |
| 794 | pronounced in Hira-gana, second, we convert Hira-gana to Kanji or Kata-Kana, |
| 795 | if needed. There are some Kana-Kanji conversion server: jserver |
Bram Moolenaar | 402d2fe | 2005-04-15 21:00:38 +0000 | [diff] [blame] | 796 | (distributed with Wnn, see below) and canna. Canna could be found at: |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 797 | ftp://ftp.nec.co.jp/pub/Canna/ (no longer works). |
| 798 | |
| 799 | There is a good input system: Wnn4.2. Wnn 4.2 contains, |
| 800 | xwnmo (|IM-server|) |
| 801 | jserver (Japanese Kana-Kanji conversion server) |
| 802 | cserver (Chinese PinYin or ZhuYin to simplified HanZi conversion server) |
| 803 | tserver (Chinese PinYin or ZhuYin to traditional HanZi conversion server) |
| 804 | kserver (Hangul-Hanja conversion server) |
| 805 | Wnn 4.2 for several systems can be found at various places on the internet. |
| 806 | Use the RPM or port for your system. |
| 807 | |
| 808 | |
| 809 | - Input Style |
| 810 | *xim-input-style* |
| 811 | When inputting CJK, there are four areas: |
| 812 | 1. The area to display of the input while it is being composed |
| 813 | 2. The area to display the currently active input mode. |
| 814 | 3. The area to display the next candidate for the selection. |
| 815 | 4. The area to display other tools. |
| 816 | |
| 817 | The third area is needed when converting. For example, in Japanese |
| 818 | inputting, multiple Kanji characters could have the same pronunciation, so |
| 819 | a sequence of Hira-gana characters could map to a distinct sequence of Kanji |
| 820 | characters. |
| 821 | |
| 822 | The first and second areas are defined in international input of X with the |
| 823 | names of "Preedit Area", "Status Area" respectively. The third and fourth |
| 824 | areas are not defined and are left to be managed by the |IM-server|. In the |
| 825 | international input, four input styles have been defined using combinations |
| 826 | of Preedit Area and Status Area: |OnTheSpot|, |OffTheSpot|, |OverTheSpot| |
| 827 | and |Root|. |
| 828 | |
| 829 | Currently, GUI Vim support three style, |OverTheSpot|, |OffTheSpot| and |
| 830 | |Root|. |
| 831 | |
| 832 | *. on-the-spot *OnTheSpot* |
| 833 | Preedit Area and Status Area are performed by the client application in |
| 834 | the area of application. The client application is directed by the |
| 835 | |IM-server| to display all pre-edit data at the location of text |
Bram Moolenaar | 402d2fe | 2005-04-15 21:00:38 +0000 | [diff] [blame] | 836 | insertion. The client registers callbacks invoked by the input method |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 837 | during pre-editing. |
| 838 | *. over-the-spot *OverTheSpot* |
| 839 | Status Area is created in a fixed position within the area of application, |
| 840 | in case of Vim, the position is the additional status line. Preedit Area |
| 841 | is made at present input position of application. The input method |
| 842 | displays pre-edit data in a window which it brings up directly over the |
| 843 | text insertion position. |
| 844 | *. off-the-spot *OffTheSpot* |
| 845 | Preedit Area and Status Area are performed in the area of application, in |
| 846 | case of Vim, the area is additional status line. The client application |
| 847 | provides display windows for the pre-edit data to the input method which |
| 848 | displays into them directly. |
| 849 | *. root-window *Root* |
| 850 | Preedit Area and Status Area are outside of the application. The input |
| 851 | method displays all pre-edit data in a separate area of the screen in a |
| 852 | window specific to the input method. |
| 853 | |
| 854 | |
| 855 | USING XIM *multibyte-input* *E284* *E286* *E287* *E288* |
| 856 | *E285* *E291* *E292* *E290* *E289* |
| 857 | |
| 858 | Note that Display and Input are independent. It is possible to see your |
| 859 | language even though you have no input method for it. But when your Display |
| 860 | method doesn't match your Input method, the text will be displayed wrong. |
| 861 | |
| 862 | Note: You can not use IM unless you specify 'guifontset'. |
| 863 | Therefore, Latin users, you have to also use 'guifontset' |
| 864 | if you use IM. |
| 865 | |
| 866 | To input your language you should run the |IM-server| which supports your |
| 867 | language and |conversion-server| if needed. |
| 868 | |
| 869 | The next 3 lines should be put in your ~/.Xdefaults file. They are common for |
| 870 | all X applications which uses |XIM|. If you already use |XIM|, you can skip |
| 871 | this. > |
| 872 | |
| 873 | *international: True |
| 874 | *.inputMethod: your_input_server_name |
| 875 | *.preeditType: your_input_style |
| 876 | < |
| 877 | input_server_name is your |IM-server| name (check your |IM-server| |
| 878 | manual). |
| 879 | your_input_style is one of |OverTheSpot|, |OffTheSpot|, |Root|. See |
| 880 | also |xim-input-style|. |
| 881 | |
| 882 | *international may not necessary if you use X11R6. |
| 883 | *.inputMethod and *.preeditType are optional if you use X11R6. |
| 884 | |
| 885 | For example, when you are using kinput2 as |IM-server|, > |
| 886 | |
| 887 | *international: True |
| 888 | *.inputMethod: kinput2 |
| 889 | *.preeditType: OverTheSpot |
| 890 | < |
| 891 | When using |OverTheSpot|, GUI Vim always connects to the IM Server even in |
| 892 | Normal mode, so you can input your language with commands like "f" and "r". |
| 893 | But when using one of the other two methods, GUI Vim connects to the IM Server |
| 894 | only if it is not in Normal mode. |
| 895 | |
| 896 | If your IM Server does not support |OverTheSpot|, and if you want to use your |
| 897 | language with some Normal mode command like "f" or "r", then you should use a |
| 898 | localized xterm or an xterm which supports |XIM| |
| 899 | |
| 900 | If needed, you can set the XMODIFIERS environment variable: |
| 901 | |
| 902 | sh: export XMODIFIERS="@im=input_server_name" |
| 903 | csh: setenv XMODIFIERS "@im=input_server_name" |
| 904 | |
| 905 | For example, when you are using kinput2 as |IM-server| and sh, > |
| 906 | |
| 907 | export XMODIFIERS="@im=kinput2" |
| 908 | < |
| 909 | |
| 910 | FULLY CONTROLLED XIM |
| 911 | |
| 912 | You can fully control XIM, like with IME of MS-Windows (see |multibyte-ime|). |
| 913 | This is currently only available for the GTK GUI. |
| 914 | |
| 915 | Before using fully controlled XIM, one setting is required. Set the |
| 916 | 'imactivatekey' option to the key that is used for the activation of the input |
| 917 | method. For example, when you are using kinput2 + canna as IM Server, the |
| 918 | activation key is probably Shift+Space: > |
| 919 | |
| 920 | :set imactivatekey=S-space |
| 921 | |
| 922 | See 'imactivatekey' for the format. |
| 923 | |
| 924 | ============================================================================== |
| 925 | 8. Input on MS-Windows *mbyte-IME* |
| 926 | |
| 927 | (Windows IME support) *multibyte-ime* *IME* |
| 928 | |
| 929 | {only works Windows GUI and compiled with the |+multi_byte_ime| feature} |
| 930 | |
| 931 | To input multibyte characters on Windows, you have to use Input Method Editor |
| 932 | (IME). In process of your editing text, you must switch status (on/off) of |
| 933 | IME many many many times. Because IME with status on is hooking all of your |
| 934 | key inputs, you cannot input 'j', 'k', or almost all of keys to Vim directly. |
| 935 | |
| 936 | This |+multi_byte_ime| feature help this. It reduce times of switch status of |
| 937 | IME manually. In normal mode, there are almost no need working IME, even |
| 938 | editing multibyte text. So exiting insert mode with ESC, Vim memorize last |
| 939 | status of IME and force turn off IME. When re-enter insert mode, Vim revert |
| 940 | IME status to that memorized automatically. |
| 941 | |
| 942 | This works on not only insert-normal mode, but also search-command input and |
| 943 | replace mode. |
| 944 | The options 'iminsert', 'imsearch' and 'imcmdline' can be used to chose |
Bram Moolenaar | 69a7cb4 | 2004-06-20 12:51:53 +0000 | [diff] [blame] | 945 | the different input methods or disable them temporarily. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 946 | |
| 947 | WHAT IS IME |
| 948 | IME is a part of East asian version Windows. That helps you to input |
| 949 | multibyte character. English and other language version Windows does not |
| 950 | have any IME. (Also there are no need usually.) But there is one that |
| 951 | called Microsoft Global IME. Global IME is a part of Internet Explorer |
| 952 | 4.0 or above. You can get more information about Global IME, at below |
| 953 | URL. |
| 954 | |
| 955 | WHAT IS GLOBAL IME *global-ime* |
| 956 | Global IME makes capability to input Chinese, Japanese, and Korean text |
| 957 | into Vim buffer on any language version of Windows 98, Windows 95, and |
| 958 | Windows NT 4.0. |
| 959 | On Windows 2000 and XP it should work as well (without downloading). On |
| 960 | Windows 2000 Professional, Global IME is built in, and the Input Locales |
| 961 | can be added through Control Panel/Regional Options/Input Locales. |
| 962 | Please see below URL for detail of Global IME. You can also find various |
| 963 | language version of Global IME at same place. |
| 964 | |
| 965 | - Global IME detailed information. |
| 966 | http://www.microsoft.com/windows/ie/features/ime.asp |
| 967 | |
| 968 | - Active Input Method Manager (Global IME) |
| 969 | http://msdn.microsoft.com/workshop/misc/AIMM/aimm.asp |
| 970 | |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 971 | Support for Global IME is an experimental feature. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 972 | |
| 973 | NOTE: For IME to work you must make sure the input locales of your language |
| 974 | are added to your system. The exact location of this depends on the version |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 975 | of Windows you use. For example, on my Windows 2000 box: |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 976 | 1. Control Panel |
| 977 | 2. Regional Options |
| 978 | 3. Input Locales Tab |
| 979 | 4. Add Installed input locales -> Chinese(PRC) |
| 980 | The default is still English (United Stated) |
| 981 | |
| 982 | |
| 983 | Cursor color when IME or XIM is on *CursorIM* |
| 984 | There is a little cute feature for IME. Cursor can indicate status of IME |
| 985 | by changing its color. Usually status of IME was indicated by little icon |
| 986 | at a corner of desktop (or taskbar). It is not easy to verify status of |
| 987 | IME. But this feature help this. |
| 988 | This works in the same way when using XIM. |
| 989 | |
| 990 | You can select cursor color when status is on by using highlight group |
Bram Moolenaar | 910f66f | 2006-04-05 20:41:53 +0000 | [diff] [blame] | 991 | CursorIM. For example, add these lines to your |gvimrc|: > |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 992 | |
| 993 | if has('multi_byte_ime') |
| 994 | highlight Cursor guifg=NONE guibg=Green |
| 995 | highlight CursorIM guifg=NONE guibg=Purple |
| 996 | endif |
| 997 | < |
| 998 | Cursor color with off IME is green. And purple cursor indicates that |
| 999 | status is on. |
| 1000 | |
| 1001 | ============================================================================== |
| 1002 | 9. Input with a keymap *mbyte-keymap* |
| 1003 | |
| 1004 | When the keyboard doesn't produce the characters you want to enter in your |
| 1005 | text, you can use the 'keymap' option. This will translate one or more |
| 1006 | (English) characters to another (non-English) character. This only happens |
| 1007 | when typing text, not when typing Vim commands. This avoids having to switch |
| 1008 | between two keyboard settings. |
| 1009 | |
| 1010 | The value of the 'keymap' option specifies a keymap file to use. The name of |
| 1011 | this file is one of these two: |
| 1012 | |
| 1013 | keymap/{keymap}_{encoding}.vim |
| 1014 | keymap/{keymap}.vim |
| 1015 | |
| 1016 | Here {keymap} is the value of the 'keymap' option and {encoding} of the |
| 1017 | 'encoding' option. The file name with the {encoding} included is tried first. |
| 1018 | |
| 1019 | 'runtimepath' is used to find these files. To see an overview of all |
| 1020 | available keymap files, use this: > |
| 1021 | :echo globpath(&rtp, "keymap/*.vim") |
| 1022 | |
| 1023 | In Insert and Command-line mode you can use CTRL-^ to toggle between using the |
| 1024 | keyboard map or not. |i_CTRL-^| |c_CTRL-^| |
| 1025 | This flag is remembered for Insert mode with the 'iminsert' option. When |
| 1026 | leaving and entering Insert mode the previous value is used. The same value |
| 1027 | is also used for commands that take a single character argument, like |f| and |
| 1028 | |r|. |
| 1029 | For Command-line mode the flag is NOT remembered. You are expected to type an |
| 1030 | Ex command first, which is ASCII. |
| 1031 | For typing search patterns the 'imsearch' option is used. It can be set to |
| 1032 | use the same value as for 'iminsert'. |
Bram Moolenaar | 8f3f58f | 2010-01-06 20:52:26 +0100 | [diff] [blame] | 1033 | *lCursor* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1034 | It is possible to give the GUI cursor another color when the language mappings |
| 1035 | are being used. This is disabled by default, to avoid that the cursor becomes |
| 1036 | invisible when you use a non-standard background color. Here is an example to |
| 1037 | use a brightly colored cursor: > |
| 1038 | :highlight Cursor guifg=NONE guibg=Green |
| 1039 | :highlight lCursor guifg=NONE guibg=Cyan |
| 1040 | < |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 1041 | *keymap-file-format* *:loadk* *:loadkeymap* *E105* *E791* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1042 | The keymap file looks something like this: > |
| 1043 | |
| 1044 | " Maintainer: name <email@address> |
| 1045 | " Last Changed: 2001 Jan 1 |
| 1046 | |
| 1047 | let b:keymap_name = "short" |
| 1048 | |
| 1049 | loadkeymap |
| 1050 | a A |
| 1051 | b B comment |
| 1052 | |
| 1053 | The lines starting with a " are comments and will be ignored. Blank lines are |
| 1054 | also ignored. The lines with the mappings may have a comment after the useful |
| 1055 | text. |
| 1056 | |
| 1057 | The "b:keymap_name" can be set to a short name, which will be shown in the |
| 1058 | status line. The idea is that this takes less room than the value of |
| 1059 | 'keymap', which might be long to distinguish between different languages, |
| 1060 | keyboards and encodings. |
| 1061 | |
| 1062 | The actual mappings are in the lines below "loadkeymap". In the example "a" |
| 1063 | is mapped to "A" and "b" to "B". Thus the first item is mapped to the second |
| 1064 | item. This is done for each line, until the end of the file. |
| 1065 | These items are exactly the same as what can be used in a |:lnoremap| command, |
| 1066 | using "<buffer>" to make the mappings local to the buffer.. |
| 1067 | You can check the result with this command: > |
| 1068 | :lmap |
| 1069 | The two items must be separated by white space. You cannot include white |
| 1070 | space inside an item, use the special names "<Tab>" and "<Space>" instead. |
| 1071 | The length of the two items together must not exceed 200 bytes. |
| 1072 | |
| 1073 | It's possible to have more than one character in the first column. This works |
| 1074 | like a dead key. Example: > |
| 1075 | 'a á |
| 1076 | Since Vim doesn't know if the next character after a quote is really an "a", |
| 1077 | it will wait for the next character. To be able to insert a single quote, |
| 1078 | also add this line: > |
| 1079 | '' ' |
| 1080 | Since the mapping is defined with |:lnoremap| the resulting quote will not be |
| 1081 | used for the start of another character. |
Bram Moolenaar | e2f98b9 | 2006-03-29 21:18:24 +0000 | [diff] [blame] | 1082 | The "accents" keymap uses this. *keymap-accents* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1083 | |
| 1084 | Although it's possible to have more than one character in the second column, |
| 1085 | this is unusual. But you can use various ways to specify the character: > |
| 1086 | A a literal character |
| 1087 | A <char-97> decimal value |
| 1088 | A <char-0x61> hexadecimal value |
| 1089 | A <char-0141> octal value |
| 1090 | x <Space> special key name |
| 1091 | |
| 1092 | The characters are assumed to be encoded for the current value of 'encoding'. |
| 1093 | It's possible to use ":scriptencoding" when all characters are given |
| 1094 | literally. That doesn't work when using the <char-> construct, because the |
| 1095 | conversion is done on the keymap file, not on the resulting character. |
| 1096 | |
| 1097 | The lines after "loadkeymap" are interpreted with 'cpoptions' set to "C". |
| 1098 | This means that continuation lines are not used and a backslash has a special |
| 1099 | meaning in the mappings. Examples: > |
| 1100 | |
| 1101 | " a comment line |
| 1102 | \" x maps " to x |
| 1103 | \\ y maps \ to y |
| 1104 | |
| 1105 | If you write a keymap file that will be useful for others, consider submitting |
| 1106 | it to the Vim maintainer for inclusion in the distribution: |
| 1107 | <maintainer@vim.org> |
| 1108 | |
| 1109 | |
| 1110 | HEBREW KEYMAP *keymap-hebrew* |
| 1111 | |
| 1112 | This file explains what characters are available in UTF-8 and CP1255 encodings, |
| 1113 | and what the keymaps are to get those characters: |
| 1114 | |
| 1115 | glyph encoding keymap ~ |
| 1116 | Char utf-8 cp1255 hebrew hebrewp name ~ |
| 1117 | א 0x5d0 0xe0 t a 'alef |
| 1118 | ב 0x5d1 0xe1 c b bet |
| 1119 | ג 0x5d2 0xe2 d g gimel |
| 1120 | ד 0x5d3 0xe3 s d dalet |
| 1121 | ה 0x5d4 0xe4 v h he |
| 1122 | ו 0x5d5 0xe5 u v vav |
| 1123 | ז 0x5d6 0xe6 z z zayin |
| 1124 | ח 0x5d7 0xe7 j j het |
| 1125 | ט 0x5d8 0xe8 y T tet |
| 1126 | י 0x5d9 0xe9 h y yod |
| 1127 | ך 0x5da 0xea l K kaf sofit |
| 1128 | כ 0x5db 0xeb f k kaf |
| 1129 | ל 0x5dc 0xec k l lamed |
| 1130 | ם 0x5dd 0xed o M mem sofit |
| 1131 | מ 0x5de 0xee n m mem |
| 1132 | ן 0x5df 0xef i N nun sofit |
| 1133 | נ 0x5e0 0xf0 b n nun |
| 1134 | ס 0x5e1 0xf1 x s samech |
| 1135 | ע 0x5e2 0xf2 g u `ayin |
| 1136 | ף 0x5e3 0xf3 ; P pe sofit |
| 1137 | פ 0x5e4 0xf4 p p pe |
| 1138 | ץ 0x5e5 0xf5 . X tsadi sofit |
| 1139 | צ 0x5e6 0xf6 m x tsadi |
| 1140 | ק 0x5e7 0xf7 e q qof |
| 1141 | ר 0x5e8 0xf8 r r resh |
| 1142 | ש 0x5e9 0xf9 a w shin |
| 1143 | ת 0x5ea 0xfa , t tav |
| 1144 | |
| 1145 | Vowel marks and special punctuation: |
| 1146 | הְ 0x5b0 0xc0 A: A: sheva |
| 1147 | הֱ 0x5b1 0xc1 HE HE hataf segol |
| 1148 | הֲ 0x5b2 0xc2 HA HA hataf patah |
| 1149 | הֳ 0x5b3 0xc3 HO HO hataf qamats |
| 1150 | הִ 0x5b4 0xc4 I I hiriq |
| 1151 | הֵ 0x5b5 0xc5 AY AY tsere |
| 1152 | הֶ 0x5b6 0xc6 E E segol |
| 1153 | הַ 0x5b7 0xc7 AA AA patah |
| 1154 | הָ 0x5b8 0xc8 AO AO qamats |
| 1155 | הֹ 0x5b9 0xc9 O O holam |
| 1156 | הֻ 0x5bb 0xcb U U qubuts |
| 1157 | כּ 0x5bc 0xcc D D dagesh |
| 1158 | הֽ 0x5bd 0xcd ]T ]T meteg |
| 1159 | ה־ 0x5be 0xce ]Q ]Q maqaf |
| 1160 | בֿ 0x5bf 0xcf ]R ]R rafe |
| 1161 | ב׀ 0x5c0 0xd0 ]p ]p paseq |
| 1162 | שׁ 0x5c1 0xd1 SR SR shin-dot |
| 1163 | שׂ 0x5c2 0xd2 SL SL sin-dot |
| 1164 | ׃ 0x5c3 0xd3 ]P ]P sof-pasuq |
| 1165 | װ 0x5f0 0xd4 VV VV double-vav |
| 1166 | ױ 0x5f1 0xd5 VY VY vav-yod |
| 1167 | ײ 0x5f2 0xd6 YY YY yod-yod |
| 1168 | |
| 1169 | The following are only available in utf-8 |
| 1170 | |
| 1171 | Cantillation marks: |
| 1172 | glyph |
| 1173 | Char utf-8 hebrew name |
| 1174 | ב֑ 0x591 C: etnahta |
| 1175 | ב֒ 0x592 Cs segol |
| 1176 | ב֓ 0x593 CS shalshelet |
| 1177 | ב֔ 0x594 Cz zaqef qatan |
| 1178 | ב֕ 0x595 CZ zaqef gadol |
| 1179 | ב֖ 0x596 Ct tipeha |
| 1180 | ב֗ 0x597 Cr revia |
| 1181 | ב֘ 0x598 Cq zarqa |
| 1182 | ב֙ 0x599 Cp pashta |
| 1183 | ב֚ 0x59a C! yetiv |
| 1184 | ב֛ 0x59b Cv tevir |
| 1185 | ב֜ 0x59c Cg geresh |
| 1186 | ב֝ 0x59d C* geresh qadim |
| 1187 | ב֞ 0x59e CG gershayim |
| 1188 | ב֟ 0x59f CP qarnei-parah |
| 1189 | ב֪ 0x5aa Cy yerach-ben-yomo |
| 1190 | ב֫ 0x5ab Co ole |
| 1191 | ב֬ 0x5ac Ci iluy |
| 1192 | ב֭ 0x5ad Cd dehi |
| 1193 | ב֮ 0x5ae Cn zinor |
| 1194 | ב֯ 0x5af CC masora circle |
| 1195 | |
| 1196 | Combining forms: |
| 1197 | ﬠ 0xfb20 X` Alternative `ayin |
| 1198 | ﬡ 0xfb21 X' Alternative 'alef |
| 1199 | ﬢ 0xfb22 X-d Alternative dalet |
| 1200 | ﬣ 0xfb23 X-h Alternative he |
| 1201 | ﬤ 0xfb24 X-k Alternative kaf |
| 1202 | ﬥ 0xfb25 X-l Alternative lamed |
| 1203 | ﬦ 0xfb26 X-m Alternative mem-sofit |
| 1204 | ﬧ 0xfb27 X-r Alternative resh |
| 1205 | ﬨ 0xfb28 X-t Alternative tav |
| 1206 | ﬩ 0xfb29 X-+ Alternative plus |
| 1207 | שׁ 0xfb2a XW shin+shin-dot |
| 1208 | שׂ 0xfb2b Xw shin+sin-dot |
| 1209 | שּׁ 0xfb2c X..W shin+shin-dot+dagesh |
| 1210 | שּׂ 0xfb2d X..w shin+sin-dot+dagesh |
| 1211 | אַ 0xfb2e XA alef+patah |
| 1212 | אָ 0xfb2f XO alef+qamats |
| 1213 | אּ 0xfb30 XI alef+hiriq (mapiq) |
| 1214 | בּ 0xfb31 X.b bet+dagesh |
| 1215 | גּ 0xfb32 X.g gimel+dagesh |
| 1216 | דּ 0xfb33 X.d dalet+dagesh |
| 1217 | הּ 0xfb34 X.h he+dagesh |
| 1218 | וּ 0xfb35 Xu vav+dagesh |
| 1219 | זּ 0xfb36 X.z zayin+dagesh |
| 1220 | טּ 0xfb38 X.T tet+dagesh |
| 1221 | יּ 0xfb39 X.y yud+dagesh |
| 1222 | ךּ 0xfb3a X.K kaf sofit+dagesh |
| 1223 | כּ 0xfb3b X.k kaf+dagesh |
| 1224 | לּ 0xfb3c X.l lamed+dagesh |
| 1225 | מּ 0xfb3e X.m mem+dagesh |
| 1226 | נּ 0xfb40 X.n nun+dagesh |
| 1227 | סּ 0xfb41 X.s samech+dagesh |
| 1228 | ףּ 0xfb43 X.P pe sofit+dagesh |
| 1229 | פּ 0xfb44 X.p pe+dagesh |
| 1230 | צּ 0xfb46 X.x tsadi+dagesh |
| 1231 | קּ 0xfb47 X.q qof+dagesh |
| 1232 | רּ 0xfb48 X.r resh+dagesh |
| 1233 | שּ 0xfb49 X.w shin+dagesh |
| 1234 | תּ 0xfb4a X.t tav+dagesh |
| 1235 | וֹ 0xfb4b Xo vav+holam |
| 1236 | בֿ 0xfb4c XRb bet+rafe |
| 1237 | כֿ 0xfb4d XRk kaf+rafe |
| 1238 | פֿ 0xfb4e XRp pe+rafe |
| 1239 | ﭏ 0xfb4f Xal alef-lamed |
| 1240 | |
| 1241 | ============================================================================== |
| 1242 | 10. Using UTF-8 *mbyte-utf8* *UTF-8* *utf-8* *utf8* |
| 1243 | *Unicode* *unicode* |
| 1244 | The Unicode character set was designed to include all characters from other |
| 1245 | character sets. Therefore it is possible to write text in any language using |
| 1246 | Unicode (with a few rarely used languages excluded). And it's mostly possible |
| 1247 | to mix these languages in one file, which is impossible with other encodings. |
| 1248 | |
Bram Moolenaar | 8f3f58f | 2010-01-06 20:52:26 +0100 | [diff] [blame] | 1249 | Unicode can be encoded in several ways. The most popular one is UTF-8, which |
| 1250 | uses one or more bytes for each character and is backwards compatible with |
| 1251 | ASCII. On MS-Windows UTF-16 is also used (previously UCS-2), which uses |
| 1252 | 16-bit words. Vim can support all of these encodings, but always uses UTF-8 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1253 | internally. |
| 1254 | |
Bram Moolenaar | 8f3f58f | 2010-01-06 20:52:26 +0100 | [diff] [blame] | 1255 | Vim has comprehensive UTF-8 support. It works well in: |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1256 | - xterm with utf-8 support enabled |
| 1257 | - Athena, Motif and GTK GUI |
| 1258 | - MS-Windows GUI |
Bram Moolenaar | 8f3f58f | 2010-01-06 20:52:26 +0100 | [diff] [blame] | 1259 | - several other platforms |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1260 | |
| 1261 | Double-width characters are supported. This works best with 'guifontwide' or |
| 1262 | 'guifontset'. When using only 'guifont' the wide characters are drawn in the |
| 1263 | normal width and a space to fill the gap. Note that the 'guifontset' option |
| 1264 | is no longer relevant in the GTK+ 2 GUI. |
| 1265 | |
Bram Moolenaar | 8f3f58f | 2010-01-06 20:52:26 +0100 | [diff] [blame] | 1266 | *bom-bytes* |
| 1267 | When reading a file a BOM (Byte Order Mark) can be used to recognize the |
| 1268 | Unicode encoding: |
| 1269 | EF BB BF utf-8 |
| 1270 | FF FE utf-16 big endian |
| 1271 | FE FF utf-16 little endian |
| 1272 | 00 00 FE FF utf-32 big endian |
| 1273 | FF FE 00 00 utf-32 little endian |
| 1274 | |
| 1275 | Utf-8 is the recommended encoding. Note that it's difficult to tell utf-16 |
| 1276 | and utf-32 apart. Utf-16 is often used on MS-Windows, utf-32 is not |
| 1277 | widespread as file format. |
| 1278 | |
| 1279 | |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 1280 | *mbyte-combining* *mbyte-composing* |
| 1281 | A composing or combining character is used to change the meaning of the |
| 1282 | character before it. The combining characters are drawn on top of the |
Bram Moolenaar | c9b4b05 | 2006-04-30 18:54:39 +0000 | [diff] [blame] | 1283 | preceding character. |
Bram Moolenaar | 362e1a3 | 2006-03-06 23:29:24 +0000 | [diff] [blame] | 1284 | Up to two combining characters can be used by default. This can be changed |
| 1285 | with the 'maxcombine' option. |
| 1286 | When editing text a composing character is mostly considered part of the |
| 1287 | preceding character. For example "x" will delete a character and its |
| 1288 | following composing characters by default. |
| 1289 | If the 'delcombine' option is on, then pressing 'x' will delete the combining |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1290 | characters, one at a time, then the base character. But when inserting, you |
| 1291 | type the first character and the following composing characters separately, |
| 1292 | after which they will be joined. The "r" command will not allow you to type a |
| 1293 | combining character, because it doesn't know one is coming. Use "R" instead. |
| 1294 | |
| 1295 | Bytes which are not part of a valid UTF-8 byte sequence are handled like a |
| 1296 | single character and displayed as <xx>, where "xx" is the hex value of the |
| 1297 | byte. |
| 1298 | |
| 1299 | Overlong sequences are not handled specially and displayed like a valid |
| 1300 | character. However, search patterns may not match on an overlong sequence. |
| 1301 | (an overlong sequence is where more bytes are used than required for the |
| 1302 | character.) An exception is NUL (zero) which is displayed as "<00>". |
| 1303 | |
| 1304 | In the file and buffer the full range of Unicode characters can be used (31 |
| 1305 | bits). However, displaying only works for 16 bit characters, and only for the |
| 1306 | characters present in the selected font. |
| 1307 | |
| 1308 | Useful commands: |
| 1309 | - "ga" shows the decimal, hexadecimal and octal value of the character under |
Bram Moolenaar | 402d2fe | 2005-04-15 21:00:38 +0000 | [diff] [blame] | 1310 | the cursor. If there are composing characters these are shown too. (If the |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1311 | message is truncated, use ":messages"). |
| 1312 | - "g8" shows the bytes used in a UTF-8 character, also the composing |
| 1313 | characters, as hex numbers. |
| 1314 | - ":set encoding=utf-8 fileencodings=" forces using UTF-8 for all files. The |
| 1315 | default is to use the current locale for 'encoding' and set 'fileencodings' |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 1316 | to automatically detect the encoding of a file. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1317 | |
| 1318 | |
| 1319 | STARTING VIM |
| 1320 | |
| 1321 | If your current locale is in an utf-8 encoding, Vim will automatically start |
| 1322 | in utf-8 mode. |
| 1323 | |
| 1324 | If you are using another locale: > |
| 1325 | |
| 1326 | set encoding=utf-8 |
| 1327 | |
| 1328 | You might also want to select the font used for the menus. Unfortunately this |
| 1329 | doesn't always work. See the system specific remarks below, and 'langmenu'. |
| 1330 | |
| 1331 | |
| 1332 | USING UTF-8 IN X-Windows *utf-8-in-xwindows* |
| 1333 | |
| 1334 | Note: This section does not apply to the GTK+ 2 GUI. |
| 1335 | |
| 1336 | You need to specify a font to be used. For double-wide characters another |
| 1337 | font is required, which is exactly twice as wide. There are three ways to do |
| 1338 | this: |
| 1339 | |
| 1340 | 1. Set 'guifont' and let Vim find a matching 'guifontwide' |
| 1341 | 2. Set 'guifont' and 'guifontwide' |
| 1342 | 3. Set 'guifontset' |
| 1343 | |
| 1344 | See the documentation for each option for details. Example: > |
| 1345 | |
| 1346 | :set guifont=-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso10646-1 |
| 1347 | |
| 1348 | You might also want to set the font used for the menus. This only works for |
| 1349 | Motif. Use the ":hi Menu font={fontname}" command for this. |:highlight| |
| 1350 | |
| 1351 | |
| 1352 | TYPING UTF-8 *utf-8-typing* |
| 1353 | |
| 1354 | If you are using X-Windows, you should find an input method that supports |
| 1355 | utf-8. |
| 1356 | |
| 1357 | If your system does not provide support for typing utf-8, you can use the |
| 1358 | 'keymap' feature. This allows writing a keymap file, which defines a utf-8 |
| 1359 | character as a sequence of ASCII characters. See |mbyte-keymap|. |
| 1360 | |
| 1361 | Another method is to set the current locale to the language you want to use |
| 1362 | and for which you have a XIM available. Then set 'termencoding' to that |
| 1363 | language and Vim will convert the typed characters to 'encoding' for you. |
| 1364 | |
| 1365 | If everything else fails, you can type any character as four hex bytes: > |
| 1366 | |
| 1367 | CTRL-V u 1234 |
| 1368 | |
| 1369 | "1234" is interpreted as a hex number. You must type four characters, prepend |
| 1370 | a zero if necessary. |
| 1371 | |
| 1372 | |
| 1373 | COMMAND ARGUMENTS *utf-8-char-arg* |
| 1374 | |
| 1375 | Commands like |f|, |F|, |t| and |r| take an argument of one character. For |
Bram Moolenaar | df177f6 | 2005-02-22 08:39:57 +0000 | [diff] [blame] | 1376 | UTF-8 this argument may include one or two composing characters. These need |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1377 | to be produced together with the base character, Vim doesn't wait for the next |
| 1378 | character to be typed to find out if it is a composing character or not. |
| 1379 | Using 'keymap' or |:lmap| is a nice way to type these characters. |
| 1380 | |
| 1381 | The commands that search for a character in a line handle composing characters |
| 1382 | as follows. When searching for a character without a composing character, |
| 1383 | this will find matches in the text with or without composing characters. When |
| 1384 | searching for a character with a composing character, this will only find |
| 1385 | matches with that composing character. It was implemented this way, because |
| 1386 | not everybody is able to type a composing character. |
| 1387 | |
| 1388 | |
| 1389 | ============================================================================== |
| 1390 | 11. Overview of options *mbyte-options* |
| 1391 | |
| 1392 | These options are relevant for editing multi-byte files. Check the help in |
| 1393 | options.txt for detailed information. |
| 1394 | |
| 1395 | 'encoding' Encoding used for the keyboard and display. It is also the |
| 1396 | default encoding for files. |
| 1397 | |
| 1398 | 'fileencoding' Encoding of a file. When it's different from 'encoding' |
| 1399 | conversion is done when reading or writing the file. |
| 1400 | |
| 1401 | 'fileencodings' List of possible encodings of a file. When opening a file |
| 1402 | these will be tried and the first one that doesn't cause an |
| 1403 | error is used for 'fileencoding'. |
| 1404 | |
| 1405 | 'charconvert' Expression used to convert files from one encoding to another. |
| 1406 | |
| 1407 | 'formatoptions' The 'm' flag can be included to have formatting break a line |
| 1408 | at a multibyte character of 256 or higher. Thus is useful for |
| 1409 | languages where a sequence of characters can be broken |
| 1410 | anywhere. |
| 1411 | |
| 1412 | 'guifontset' The list of font names used for a multi-byte encoding. When |
| 1413 | this option is not empty, it replaces 'guifont'. |
| 1414 | |
| 1415 | 'keymap' Specify the name of a keyboard mapping. |
| 1416 | |
| 1417 | ============================================================================== |
| 1418 | |
| 1419 | Contributions specifically for the multi-byte features by: |
| 1420 | Chi-Deok Hwang <hwang@mizi.co.kr> |
Bram Moolenaar | 8f3f58f | 2010-01-06 20:52:26 +0100 | [diff] [blame] | 1421 | SungHyun Nam <goweol@gmail.com> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1422 | K.Nagano <nagano@atese.advantest.co.jp> |
| 1423 | Taro Muraoka <koron@tka.att.ne.jp> |
| 1424 | Yasuhiro Matsumoto <mattn@mail.goo.ne.jp> |
| 1425 | |
| 1426 | vim:tw=78:ts=8:ft=help:norl: |