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