aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc/mbyte.txt
blob: dd2c99669cfe201e1717436c47d8ce839a82544d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
*mbyte.txt*     Nvim


		  VIM REFERENCE MANUAL	  by Bram Moolenaar et al.


Multi-byte support				*multibyte* *multi-byte*
						*Chinese* *Japanese* *Korean*
This is about editing text in languages which have many characters that can
not be represented using one byte (one octet).  Examples are Chinese, Japanese
and Korean.  Unicode is also covered here.

For an introduction to the most common features, see |usr_45.txt| in the user
manual.
For changing the language of messages and menus see |mlang.txt|.

                                      Type |gO| to see the table of contents.

==============================================================================
Getting started						*mbyte-first*

This is a summary of the multibyte features in Vim.  If you are lucky it works
as described and you can start using Vim without much trouble.  If something
doesn't work you will have to read the rest.  Don't be surprised if it takes
quite a bit of work and experimenting to make Vim use all the multibyte
features.  Unfortunately, every system has its own way to deal with multibyte
languages and it is quite complicated.


LOCALE

First of all, you must make sure your current locale is set correctly.  If
your system has been installed to use the language, it probably works right
away.  If not, you can often make it work by setting the $LANG environment
variable in your shell: >

	setenv LANG ja_JP.EUC

Unfortunately, the name of the locale depends on your system.  Japanese might
also be called "ja_JP.EUCjp" or just "ja".  To see what is currently used: >

	:language

To change the locale inside Vim use: >

	:language ja_JP.EUC

Vim will give an error message if this doesn't work.  This is a good way to
experiment and find the locale name you want to use.  But it's always better
to set the locale in the shell, so that it is used right from the start.

See |mbyte-locale| for details.


ENCODING

Nvim always uses UTF-8 internally. Thus 'encoding' option is always set
to "utf-8" and cannot be changed.

All the text that is used inside Vim will be in UTF-8. Not only the text in
the buffers, but also in registers, variables, etc.

You can edit files in different encodings than UTF-8.  Nvim
will convert the file when you read it and convert it back when you write it.
See 'fileencoding', 'fileencodings' and |++enc|.


DISPLAY AND FONTS

If you are working in a terminal (emulator) you must make sure it accepts
UTF-8, the encoding which Vim is working with. Otherwise only ASCII can
be displayed and edited correctly.

For the GUI you must select fonts that work with UTF-8.  You can set 'guifont'
and 'guifontwide'.  'guifont' is used for the single-width characters,
'guifontwide' for the double-width characters. Thus the 'guifontwide' font
must be exactly twice as wide as 'guifont'. Example for UTF-8: >

	:set guifont=-misc-fixed-medium-r-normal-*-18-120-100-100-c-90-iso10646-1
	:set guifontwide=-misc-fixed-medium-r-normal-*-18-120-100-100-c-180-iso10646-1

You can also set 'guifont' alone, the Nvim GUI will try to find a matching
'guifontwide' for you.


INPUT

There are several ways to enter multibyte characters:
- Your system IME can be used.
- Keymaps can be used.  See |mbyte-keymap|.

The options 'iminsert', 'imsearch' and 'imcmdline' can be used to choose
the different input methods or disable them temporarily.

==============================================================================
Locale							*mbyte-locale*

The easiest setup is when your whole system uses the locale you want to work
in.  But it's also possible to set the locale for one shell you are working
in, or just use a certain locale inside Vim.


WHAT IS A LOCALE?					*locale*

There are many languages in the world.  And there are different cultures and
environments at least as many as the number of languages.  A linguistic
environment corresponding to an area is called "locale".  This includes
information about the used language, the charset, collating order for sorting,
date format, currency format and so on.  For Vim only the language and charset
really matter.

You can only use a locale if your system has support for it.  Some systems
have only a few locales, especially in the USA.  The language which you want
to use may not be on your system.  In that case you might be able to install
it as an extra package.  Check your system documentation for how to do that.

The location in which the locales are installed varies from system to system.
For example, "/usr/share/locale" or "/usr/lib/locale".  See your system's
setlocale() man page.

Looking in these directories will show you the exact name of each locale.
Mostly upper/lowercase matters, thus "ja_JP.EUC" and "ja_jp.euc" are
different.  Some systems have a locale.alias file, which allows translation
from a short name like "nl" to the full name "nl_NL.ISO_8859-1".

Note that X-windows has its own locale stuff.  And unfortunately uses locale
names different from what is used elsewhere.  This is confusing!  For Vim it
matters what the setlocale() function uses, which is generally NOT the
X-windows stuff.  You might have to do some experiments to find out what
really works.

							*locale-name*
The (simplified) format of |locale| name is:

	language
or	language_territory
or	language_territory.codeset

Territory means the country (or part of it), codeset means the |charset|.  For
example, the locale name "ja_JP.eucJP" means:
	ja	the language is Japanese
	JP	the country is Japan
	eucJP	the codeset is EUC-JP
But it also could be "ja", "ja_JP.EUC", "ja_JP.ujis", etc.  And unfortunately,
the locale name for a specific language, territory and codeset is not unified
and depends on your system.

Examples of locale name:
    charset	    language		  locale name ~
    GB2312	    Chinese (simplified)  zh_CN.EUC, zh_CN.GB2312
    Big5	    Chinese (traditional) zh_TW.BIG5, zh_TW.Big5
    CNS-11643	    Chinese (traditional) zh_TW
    EUC-JP	    Japanese		  ja, ja_JP.EUC, ja_JP.ujis, ja_JP.eucJP
    Shift_JIS	    Japanese		  ja_JP.SJIS, ja_JP.Shift_JIS
    EUC-KR	    Korean		  ko, ko_KR.EUC


USING A LOCALE

To start using a locale for the whole system, see the documentation of your
system.  Mostly you need to set it in a configuration file in "/etc".

To use a locale in a shell, set the $LANG environment value.  When you want to
use Korean and the |locale| name is "ko", do this:

    sh:    export LANG=ko
    csh:   setenv LANG ko

You can put this in your ~/.profile or ~/.cshrc file to always use it.

To use a locale in Vim only, use the |:language| command: >

	:language ko

Put this in your |init.vim| file to use it always.

Or specify $LANG when starting Vim:

   sh:    LANG=ko vim {vim-arguments}
   csh:	  env LANG=ko vim {vim-arguments}

You could make a small shell script for this.

==============================================================================
Encoding				*mbyte-encoding*

In Nvim UTF-8 is always used internally to encode characters.
 This applies to all the places where text is used, including buffers (files
 loaded into memory), registers and variables.

							*charset* *codeset*
Charset is another name for encoding.  There are subtle differences, but these
don't matter when using Vim.  "codeset" is another similar name.

Each character is encoded as one or more bytes.  When all characters are
encoded with one byte, we call this a single-byte encoding.  The most often
used one is called "latin1".  This limits the number of characters to 256.
Some of these are control characters, thus even fewer can be used for text.

When some characters use two or more bytes, we call this a multibyte
encoding.  This allows using much more than 256 characters, which is required
for most East Asian languages.

Most multibyte encodings use one byte for the first 127 characters.  These
are equal to ASCII, which makes it easy to exchange plain-ASCII text, no
matter what language is used.  Thus you might see the right text even when the
encoding was set wrong.

							*encoding-names*
Vim can edit files in different character encodings.  There are three major groups:

1   8bit	Single-byte encodings, 256 different characters.  Mostly used
		in USA and Europe.  Example: ISO-8859-1 (Latin1).  All
		characters occupy one screen cell only.

2   2byte	Double-byte encodings, over 10000 different characters.
		Mostly used in Asian countries.  Example: euc-kr (Korean)
		The number of screen cells is equal to the number of bytes
		(except for euc-jp when the first byte is 0x8e).

u   Unicode	Universal encoding, can replace all others.  ISO 10646.
		Millions of different characters.  Example: UTF-8.  The
		relation between bytes and screen cells is complex.

Only UTF-8 is used by Vim internally.  But files in other
encodings can be edited by using conversion, see 'fileencoding'.

Recognized 'fileencoding' values include:		*encoding-values*
1   latin1	8-bit characters (ISO 8859-1, also used for cp1252)
1   iso-8859-n	ISO_8859 variant (n = 2 to 15)
1   koi8-r	Russian
1   koi8-u	Ukrainian
1   macroman    MacRoman (Macintosh encoding)
1   8bit-{name} any 8-bit encoding (Vim specific name)
1   cp437	similar to iso-8859-1
1   cp737	similar to iso-8859-7
1   cp775	Baltic
1   cp850	similar to iso-8859-4
1   cp852	similar to iso-8859-1
1   cp855	similar to iso-8859-2
1   cp857	similar to iso-8859-5
1   cp860	similar to iso-8859-9
1   cp861	similar to iso-8859-1
1   cp862	similar to iso-8859-1
1   cp863	similar to iso-8859-8
1   cp865	similar to iso-8859-1
1   cp866	similar to iso-8859-5
1   cp869	similar to iso-8859-7
1   cp874	Thai
1   cp1250	Czech, Polish, etc.
1   cp1251	Cyrillic
1   cp1253	Greek
1   cp1254	Turkish
1   cp1255	Hebrew
1   cp1256	Arabic
1   cp1257	Baltic
1   cp1258	Vietnamese
1   cp{number}	MS-Windows: any installed single-byte codepage
2   cp932	Japanese (Windows only)
2   euc-jp	Japanese
2   sjis	Japanese
2   cp949	Korean
2   euc-kr	Korean
2   cp936	simplified Chinese (Windows only)
2   euc-cn	simplified Chinese
2   cp950	traditional Chinese (alias for big5)
2   big5	traditional Chinese (alias for cp950)
2   euc-tw	traditional Chinese
2   2byte-{name} any double-byte encoding (Vim-specific name)
2   cp{number}	MS-Windows: any installed double-byte codepage
u   utf-8	32 bit UTF-8 encoded Unicode (ISO/IEC 10646-1)
u   ucs-2	16 bit UCS-2 encoded Unicode (ISO/IEC 10646-1)
u   ucs-2le	like ucs-2, little endian
u   utf-16	ucs-2 extended with double-words for more characters
u   utf-16le	like utf-16, little endian
u   ucs-4	32 bit UCS-4 encoded Unicode (ISO/IEC 10646-1)
u   ucs-4le	like ucs-4, little endian

The {name} can be any encoding name that your system supports.  It is passed
to iconv() to convert between UTF-8 and the encoding of the file.
For MS-Windows "cp{number}" means using codepage {number}.
Examples: >
		:set fileencoding=8bit-cp1252
		:set fileencoding=2byte-cp932

The MS-Windows codepage 1252 is very similar to latin1.  For practical reasons
the same encoding is used and it's called latin1.  'isprint' can be used to
display the characters 0x80 - 0xA0 or not.

Several aliases can be used, they are translated to one of the names above.
Incomplete list:

1   ansi	same as latin1 (obsolete, for backward compatibility)
2   japan	Japanese: "euc-jp"
2   korea	Korean: "euc-kr"
2   prc		simplified Chinese: "euc-cn"
2   chinese     same as "prc"
2   taiwan	traditional Chinese: "euc-tw"
u   utf8	same as utf-8
u   unicode	same as ucs-2
u   ucs2be	same as ucs-2 (big endian)
u   ucs-2be	same as ucs-2 (big endian)
u   ucs-4be	same as ucs-4 (big endian)
u   utf-32	same as ucs-4
u   utf-32le	same as ucs-4le
    default     the encoding of the current locale.

For the UCS codes the byte order matters.  This is tricky, use UTF-8 whenever
you can.  The default is to use big-endian (most significant byte comes
first):
	    name	bytes		char ~
	    ucs-2	      11 22	    1122
	    ucs-2le	      22 11	    1122
	    ucs-4	11 22 33 44	11223344
	    ucs-4le	44 33 22 11	11223344

On MS-Windows systems you often want to use "ucs-2le", because it uses little
endian UCS-2.

There are a few encodings which are similar, but not exactly the same.  Vim
treats them as if they were different encodings, so that conversion will be
done when needed.  You might want to use the similar name to avoid conversion
or when conversion is not possible:

	cp932, shift-jis, sjis
	cp936, euc-cn

CONVERSION						*charset-conversion*

Vim will automatically convert from one to another encoding in several places:
- When reading a file and 'fileencoding' is different from "utf-8"
- When writing a file and 'fileencoding' is different from "utf-8"
- When displaying messages and the encoding used for LC_MESSAGES differs from
  "utf-8" (requires a gettext version that supports this).
- When reading a Vim script where |:scriptencoding| is different from
  "utf-8".
Most of these require iconv.  Conversion for reading and writing files may
also be specified with the 'charconvert' option.

Useful utilities for converting the charset:
    All:	    iconv
	GNU iconv can convert most encodings.  Unicode is used as the
	intermediate encoding, which allows conversion from and to all other
	encodings.  See http://www.gnu.org/directory/libiconv.html.

    Japanese:	    nkf
	Nkf is "Network Kanji code conversion Filter".  One of the most unique
	facility of nkf is the guess of the input Kanji code.  So, you don't
	need to know what the inputting file's |charset| is.  When convert to
	EUC-JP from ISO-2022-JP or Shift_JIS, simply do the following command
	in Vim:
	    :%!nkf -e
	Nkf can be found at:
	http://www.sfc.wide.ad.jp/~max/FreeBSD/ports/distfiles/nkf-1.62.tar.gz

    Chinese:	    hc
	Hc is "Hanzi Converter".  Hc convert a GB file to a Big5 file, or Big5
	file to GB file.  Hc can be found at:
	ftp://ftp.cuhk.hk/pub/chinese/ifcss/software/unix/convert/hc-30.tar.gz

    Korean:	    hmconv
	Hmconv is Korean code conversion utility especially for E-mail.  It can
	convert between EUC-KR and ISO-2022-KR.  Hmconv can be found at:
	ftp://ftp.kaist.ac.kr/pub/hangul/code/hmconv/

    Multilingual:   lv
	Lv is a Powerful Multilingual File Viewer.  And it can be worked as
	|charset| converter.  Supported |charset|: ISO-2022-CN, ISO-2022-JP,
	ISO-2022-KR, EUC-CN, EUC-JP, EUC-KR, EUC-TW, UTF-7, UTF-8, ISO-8859
	series, Shift_JIS, Big5 and HZ.  Lv can be found at:
	http://www.ff.iij4u.or.jp/~nrt/lv/index.html


							*mbyte-conversion*
When reading and writing files in an encoding different from "utf-8",
conversion needs to be done.  These conversions are supported:
- All conversions between Latin-1 (ISO-8859-1), UTF-8, UCS-2 and UCS-4 are
  handled internally.
- For MS-Windows, conversion from and
  to any codepage should work.
- Conversion specified with 'charconvert'
- Conversion with the iconv library, if it is available.
	Old versions of GNU iconv() may cause the conversion to fail (they
	request a very large buffer, more than Vim is willing to provide).
	Try getting another iconv() implementation.

==============================================================================
Input on X11					*mbyte-XIM*

X INPUT METHOD (XIM) BACKGROUND			*XIM* *xim* *x-input-method*

XIM is an international input module for X.  There are two kinds of structures,
Xlib unit type and |IM-server| (Input-Method server) type.  |IM-server| type
is suitable for complex input, such as CJK.

- IM-server
							*IM-server*
  In |IM-server| type input structures, the input event is handled by either
  of the two ways: FrontEnd system and BackEnd system.  In the FrontEnd
  system, input events are snatched by the |IM-server| first, then |IM-server|
  give the application the result of input.  On the other hand, the BackEnd
  system works reverse order.  MS-Windows adopt BackEnd system.  In X, most of
  |IM-server|s adopt FrontEnd system.  The demerit of BackEnd system is the
  large overhead in communication, but it provides safe synchronization with
  no restrictions on applications.

  For example, there are xwnmo and kinput2 Japanese |IM-server|, both are
  FrontEnd system.  Xwnmo is distributed with Wnn (see below), kinput2 can be
  found at: ftp://ftp.sra.co.jp/pub/x11/kinput2/

  For Chinese, there's a great XIM server named "xcin", you can input both
  Traditional and Simplified Chinese characters.  And it can accept other
  locale if you make a correct input table.  Xcin can be found at:
  http://cle.linux.org.tw/xcin/
  Others are scim: http://scim.freedesktop.org/ and fcitx:
  http://www.fcitx.org/

- Conversion Server
							*conversion-server*
  Some system needs additional server: conversion server.  Most of Japanese
  |IM-server|s need it, Kana-Kanji conversion server.  For Chinese inputting,
  it depends on the method of inputting, in some methods, PinYin or ZhuYin to
  HanZi conversion server is needed.  For Korean inputting, if you want to
  input Hanja, Hangul-Hanja conversion server is needed.

  For example, the Japanese inputting process is divided into 2 steps.  First
  we pre-input Hira-gana, second Kana-Kanji conversion.  There are so many
  Kanji characters (6349 Kanji characters are defined in JIS X 0208) and the
  number of Hira-gana characters are 76.  So, first, we pre-input text as
  pronounced in Hira-gana, second, we convert Hira-gana to Kanji or Kata-Kana,
  if needed.  There are some Kana-Kanji conversion server: jserver
  (distributed with Wnn, see below) and canna.  Canna can be found at:
  http://canna.sourceforge.jp/

There is a good input system: Wnn4.2.  Wnn 4.2 contains,
    xwnmo (|IM-server|)
    jserver (Japanese Kana-Kanji conversion server)
    cserver (Chinese PinYin or ZhuYin to simplified HanZi conversion server)
    tserver (Chinese PinYin or ZhuYin to traditional HanZi conversion server)
    kserver (Hangul-Hanja conversion server)
Wnn 4.2 for several systems can be found at various places on the internet.
Use the RPM or port for your system.


- Input Style
							*xim-input-style*
  When inputting CJK, there are four areas:
      1. The area to display of the input while it is being composed
      2. The area to display the currently active input mode.
      3. The area to display the next candidate for the selection.
      4. The area to display other tools.

  The third area is needed when converting.  For example, in Japanese
  inputting, multiple Kanji characters could have the same pronunciation, so
  a sequence of Hira-gana characters could map to a distinct sequence of Kanji
  characters.

  The first and second areas are defined in international input of X with the
  names of "Preedit Area", "Status Area" respectively.  The third and fourth
  areas are not defined and are left to be managed by the |IM-server|.  In the
  international input, four input styles have been defined using combinations
  of Preedit Area and Status Area: |OnTheSpot|, |OffTheSpot|, |OverTheSpot|
  and |Root|.

  Currently, GUI Vim supports three styles, |OverTheSpot|, |OffTheSpot| and
  |Root|.

*.  on-the-spot						*OnTheSpot*
    Preedit Area and Status Area are performed by the client application in
    the area of application.  The client application is directed by the
    |IM-server| to display all pre-edit data at the location of text
    insertion.  The client registers callbacks invoked by the input method
    during pre-editing.
*.  over-the-spot					*OverTheSpot*
    Status Area is created in a fixed position within the area of application,
    in case of Vim, the position is the additional status line.  Preedit Area
    is made at present input position of application.  The input method
    displays pre-edit data in a window which it brings up directly over the
    text insertion position.
*.  off-the-spot					*OffTheSpot*
    Preedit Area and Status Area are performed in the area of application, in
    case of Vim, the area is additional status line.  The client application
    provides display windows for the pre-edit data to the input method which
    displays into them directly.
*.  root-window						*Root*
    Preedit Area and Status Area are outside of the application.  The input
    method displays all pre-edit data in a separate area of the screen in a
    window specific to the input method.


USING XIM			*multibyte-input* *E284* *E285* *E286* *E287*
					*E288* *E289*

Note that Display and Input are independent.  It is possible to see your
language even though you have no input method for it.  But when your Display
method doesn't match your Input method, the text will be displayed wrong.

To input your language you should run the |IM-server| which supports your
language and |conversion-server| if needed.

The next 3 lines should be put in your ~/.Xdefaults file.  They are common for
all X applications which uses |XIM|.  If you already use |XIM|, you can skip
this. >

	*international: True
	*.inputMethod: your_input_server_name
	*.preeditType: your_input_style
<
input_server_name	is your |IM-server| name (check your |IM-server|
			manual).
your_input_style	is one of |OverTheSpot|, |OffTheSpot|, |Root|.  See
			also |xim-input-style|.

*international may not be necessary if you use X11R6.
*.inputMethod and *.preeditType are optional if you use X11R6.

For example, when you are using kinput2 as |IM-server|, >

	*international: True
	*.inputMethod: kinput2
	*.preeditType: OverTheSpot
<
When using |OverTheSpot|, GUI Vim always connects to the IM Server even in
Normal mode, so you can input your language with commands like "f" and "r".
But when using one of the other two methods, GUI Vim connects to the IM Server
only if it is not in Normal mode.

If your IM Server does not support |OverTheSpot|, and if you want to use your
language with some Normal mode command like "f" or "r", then you should use a
localized xterm  or an xterm which supports |XIM|

If needed, you can set the XMODIFIERS environment variable:

	sh:  export XMODIFIERS="@im=input_server_name"
	csh: setenv XMODIFIERS "@im=input_server_name"

For example, when you are using kinput2 as |IM-server| and sh, >

	export XMODIFIERS="@im=kinput2"
<

==============================================================================
Input with a keymap					*mbyte-keymap*

When the keyboard doesn't produce the characters you want to enter in your
text, you can use the 'keymap' option.  This will translate one or more
(English) characters to another (non-English) character.  This only happens
when typing text, not when typing Vim commands.  This avoids having to switch
between two keyboard settings.

The value of the 'keymap' option specifies a keymap file to use.  The name of
this file is one of these two:

	keymap/{keymap}_utf-8.vim
	keymap/{keymap}.vim

Here {keymap} is the value of the 'keymap' option.
The file name with "utf-8" included is tried first.

'runtimepath' is used to find these files.  To see an overview of all
available keymap files, use this: >
	:echo globpath(&rtp, "keymap/*.vim")

In Insert and Command-line mode you can use CTRL-^ to toggle between using the
keyboard map or not. |i_CTRL-^| |c_CTRL-^|
This flag is remembered for Insert mode with the 'iminsert' option.  When
leaving and entering Insert mode the previous value is used.  The same value
is also used for commands that take a single character argument, like |f| and
|r|.
For Command-line mode the flag is NOT remembered.  You are expected to type an
Ex command first, which is ASCII.
For typing search patterns the 'imsearch' option is used.  It can be set to
use the same value as for 'iminsert'.
								*lCursor*
It is possible to give the GUI cursor another color when the language mappings
are being used.  This is disabled by default, to avoid that the cursor becomes
invisible when you use a non-standard background color.  Here is an example to
use a brightly colored cursor: >
	:highlight Cursor guifg=NONE guibg=Green
	:highlight lCursor guifg=NONE guibg=Cyan
<
		*keymap-file-format* *:loadk* *:loadkeymap* *E105* *E791*
The keymap file looks something like this: >

	" Maintainer:	name <email@address>
	" Last Changed:	2001 Jan 1

	let b:keymap_name = "short"

	loadkeymap
	a	A
	b	B	comment

The lines starting with a " are comments and will be ignored.  Blank lines are
also ignored.  The lines with the mappings may have a comment after the useful
text.

The "b:keymap_name" can be set to a short name, which will be shown in the
status line.  The idea is that this takes less room than the value of
'keymap', which might be long to distinguish between different languages,
keyboards and encodings.

The actual mappings are in the lines below "loadkeymap".  In the example "a"
is mapped to "A" and "b" to "B".  Thus the first item is mapped to the second
item.  This is done for each line, until the end of the file.
These items are exactly the same as what can be used in a |:lmap| command,
using "<buffer>" to make the mappings local to the buffer.
You can check the result with this command: >
	:lmap
The two items must be separated by white space.  You cannot include white
space inside an item, use the special names "<Tab>" and "<Space>" instead.
The length of the two items together must not exceed 200 bytes.

It's possible to have more than one character in the first column.  This works
like a dead key.  Example: >
	'a	á
Since Vim doesn't know if the next character after a quote is really an "a",
it will wait for the next character.  To be able to insert a single quote,
also add this line: >
	''	'
Since the mapping is defined with |:lmap| the resulting quote will not be
used for the start of another character defined in the 'keymap'.
It can be used in a standard |:imap| mapping.
The "accents" keymap uses this.				*keymap-accents*

The first column can also be in |<>| form:
	<C-c>		Ctrl-C
	<A-c>		Alt-c
	<A-C>		Alt-C
Note that the Alt mappings may not work, depending on your keyboard and
terminal.

Although it's possible to have more than one character in the second column,
this is unusual.  But you can use various ways to specify the character: >
	A	a		literal character
	A	<char-97>	decimal value
	A	<char-0x61>	hexadecimal value
	A	<char-0141>	octal value
	x	<Space>		special key name

The characters are assumed to be encoded in UTF-8.
It's possible to use ":scriptencoding" when all characters are given
literally.  That doesn't work when using the <char-> construct, because the
conversion is done on the keymap file, not on the resulting character.

The lines after "loadkeymap" are interpreted with 'cpoptions' set to "C".
This means that continuation lines are not used and a backslash has a special
meaning in the mappings.  Examples: >

	" a comment line
	\"	x	maps " to x
	\\	y	maps \ to y

If you write a keymap file that will be useful for others, consider submitting
it to the Vim maintainer for inclusion in the distribution:
<maintainer@vim.org>


HEBREW KEYMAP						*keymap-hebrew*

This file explains what characters are available in UTF-8 and CP1255 encodings,
and what the keymaps are to get those characters:

glyph   encoding	   keymap ~
Char UTF-8 cp1255  hebrew  hebrewp  name ~
א    0x5d0  0xe0     t	      a     'alef
ב    0x5d1  0xe1     c	      b     bet
ג    0x5d2  0xe2     d	      g     gimel
ד    0x5d3  0xe3     s	      d     dalet
ה    0x5d4  0xe4     v	      h     he
ו    0x5d5  0xe5     u	      v     vav
ז    0x5d6  0xe6     z	      z     zayin
ח    0x5d7  0xe7     j	      j     het
ט    0x5d8  0xe8     y	      T     tet
י    0x5d9  0xe9     h	      y     yod
ך    0x5da  0xea     l	      K     kaf sofit
כ    0x5db  0xeb     f	      k     kaf
ל    0x5dc  0xec     k	      l     lamed
ם    0x5dd  0xed     o	      M     mem sofit
מ    0x5de  0xee     n	      m     mem
ן    0x5df  0xef     i	      N     nun sofit
נ    0x5e0  0xf0     b	      n     nun
ס    0x5e1  0xf1     x	      s     samech
ע    0x5e2  0xf2     g	      u     `ayin
ף    0x5e3  0xf3     ;	      P     pe sofit
פ    0x5e4  0xf4     p	      p     pe
ץ    0x5e5  0xf5     .	      X     tsadi sofit
צ    0x5e6  0xf6     m	      x     tsadi
ק    0x5e7  0xf7     e	      q     qof
ר    0x5e8  0xf8     r	      r     resh
ש    0x5e9  0xf9     a	      w     shin
ת    0x5ea  0xfa     ,	      t     tav

Vowel marks and special punctuation:
הְ    0x5b0  0xc0     A:      A:   sheva
הֱ    0x5b1  0xc1     HE      HE   hataf segol
הֲ    0x5b2  0xc2     HA      HA   hataf patah
הֳ    0x5b3  0xc3     HO      HO   hataf qamats
הִ    0x5b4  0xc4     I       I    hiriq
הֵ    0x5b5  0xc5     AY      AY   tsere
הֶ    0x5b6  0xc6     E       E    segol
הַ    0x5b7  0xc7     AA      AA   patah
הָ    0x5b8  0xc8     AO      AO   qamats
הֹ    0x5b9  0xc9     O       O    holam
הֻ    0x5bb  0xcb     U       U    qubuts
כּ    0x5bc  0xcc     D       D    dagesh
הֽ    0x5bd  0xcd     ]T      ]T   meteg
ה־   0x5be  0xce     ]Q      ]Q   maqaf
בֿ    0x5bf  0xcf     ]R      ]R   rafe
ב׀   0x5c0  0xd0     ]p      ]p   paseq
שׁ    0x5c1  0xd1     SR      SR   shin-dot
שׂ    0x5c2  0xd2     SL      SL   sin-dot
׃    0x5c3  0xd3     ]P      ]P   sof-pasuq
װ    0x5f0  0xd4     VV      VV   double-vav
ױ    0x5f1  0xd5     VY      VY   vav-yod
ײ    0x5f2  0xd6     YY      YY   yod-yod

The following are only available in UTF-8

Cantillation marks:
glyph
Char UTF-8 hebrew name
ב֑    0x591   C:   etnahta
ב֒    0x592   Cs   segol
ב֓    0x593   CS   shalshelet
ב֔    0x594   Cz   zaqef qatan
ב֕    0x595   CZ   zaqef gadol
ב֖    0x596   Ct   tipeha
ב֗    0x597   Cr   revia
ב֘    0x598   Cq   zarqa
ב֙    0x599   Cp   pashta
ב֚    0x59a   C!   yetiv
ב֛    0x59b   Cv   tevir
ב֜    0x59c   Cg   geresh
ב֝    0x59d   C*   geresh qadim
ב֞    0x59e   CG   gershayim
ב֟    0x59f   CP   qarnei-parah
ב֪    0x5aa   Cy   yerach-ben-yomo
ב֫    0x5ab   Co   ole
ב֬    0x5ac   Ci   iluy
ב֭    0x5ad   Cd   dehi
ב֮    0x5ae   Cn   zinor
ב֯    0x5af   CC   masora circle

Combining forms:
ﬠ    0xfb20  X`   Alternative `ayin
ﬡ    0xfb21  X'   Alternative 'alef
ﬢ    0xfb22  X-d  Alternative dalet
ﬣ    0xfb23  X-h  Alternative he
ﬤ    0xfb24  X-k  Alternative kaf
ﬥ    0xfb25  X-l  Alternative lamed
ﬦ    0xfb26  X-m  Alternative mem-sofit
ﬧ    0xfb27  X-r  Alternative resh
ﬨ    0xfb28  X-t  Alternative tav
﬩    0xfb29  X-+  Alternative plus
שׁ    0xfb2a  XW   shin+shin-dot
שׂ    0xfb2b  Xw   shin+sin-dot
שּׁ    0xfb2c  X..W  shin+shin-dot+dagesh
שּׂ    0xfb2d  X..w  shin+sin-dot+dagesh
אַ    0xfb2e  XA   alef+patah
אָ    0xfb2f  XO   alef+qamats
אּ    0xfb30  XI   alef+hiriq (mapiq)
בּ    0xfb31  X.b  bet+dagesh
גּ    0xfb32  X.g  gimel+dagesh
דּ    0xfb33  X.d  dalet+dagesh
הּ    0xfb34  X.h  he+dagesh
וּ    0xfb35  Xu  vav+dagesh
זּ    0xfb36  X.z  zayin+dagesh
טּ    0xfb38  X.T  tet+dagesh
יּ    0xfb39  X.y  yud+dagesh
ךּ    0xfb3a  X.K  kaf sofit+dagesh
כּ    0xfb3b  X.k  kaf+dagesh
לּ    0xfb3c  X.l  lamed+dagesh
מּ    0xfb3e  X.m  mem+dagesh
נּ    0xfb40  X.n  nun+dagesh
סּ    0xfb41  X.s  samech+dagesh
ףּ    0xfb43  X.P  pe sofit+dagesh
פּ    0xfb44  X.p  pe+dagesh
צּ    0xfb46  X.x  tsadi+dagesh
קּ    0xfb47  X.q  qof+dagesh
רּ    0xfb48  X.r  resh+dagesh
שּ    0xfb49  X.w  shin+dagesh
תּ    0xfb4a  X.t  tav+dagesh
וֹ    0xfb4b  Xo   vav+holam
בֿ    0xfb4c  XRb  bet+rafe
כֿ    0xfb4d  XRk  kaf+rafe
פֿ    0xfb4e  XRp  pe+rafe
ﭏ    0xfb4f  Xal  alef-lamed

==============================================================================
Using UTF-8				*mbyte-utf8* *UTF-8* *utf-8* *utf8*
							*Unicode* *unicode*
The Unicode character set was designed to include all characters from other
character sets.  Therefore it is possible to write text in any language using
Unicode (with a few rarely used languages excluded).  And it's mostly possible
to mix these languages in one file, which is impossible with other encodings.

Unicode can be encoded in several ways.  The most popular one is UTF-8, which
uses one or more bytes for each character and is backwards compatible with
ASCII.   On MS-Windows UTF-16 is also used (previously UCS-2), which uses
16-bit words.  Vim can support all of these encodings, but always uses UTF-8
internally.

Vim has comprehensive UTF-8 support.  It works well in:
- xterm with UTF-8 support enabled
- MS-Windows GUI
- several other platforms

Double-width characters are supported.  Works best with 'guifontwide'.  When
using only 'guifont' the wide characters are drawn in the normal width and
a space to fill the gap.

							*bom-bytes*
When reading a file a BOM (Byte Order Mark) can be used to recognize the
Unicode encoding:
	EF BB BF     UTF-8
	FE FF        UTF-16 big endian
	FF FE        UTF-16 little endian
	00 00 FE FF  UTF-32 big endian
	FF FE 00 00  UTF-32 little endian

UTF-8 is the recommended encoding.  Note that it's difficult to tell UTF-16
and UTF-32 apart.  UTF-16 is often used on MS-Windows, UTF-32 is not
widespread as file format.


					*mbyte-combining* *mbyte-composing*
A composing or combining character is used to change the meaning of the
character before it.  The combining characters are drawn on top of the
preceding character.
Up to six combining characters can be displayed.
When editing text a composing character is mostly considered part of the
preceding character.  For example "x" will delete a character and its
following composing characters by default.
If the 'delcombine' option is on, then pressing 'x' will delete the combining
characters, one at a time, then the base character.  But when inserting, you
type the first character and the following composing characters separately,
after which they will be joined.  The "r" command will not allow you to type a
combining character, because it doesn't know one is coming.  Use "R" instead.

Bytes which are not part of a valid UTF-8 byte sequence are handled like a
single character and displayed as <xx>, where "xx" is the hex value of the
byte.

Overlong sequences are not handled specially and displayed like a valid
character.  However, search patterns may not match on an overlong sequence.
(an overlong sequence is where more bytes are used than required for the
character.)  An exception is NUL (zero) which is displayed as "<00>".

In the file and buffer the full range of Unicode characters can be used (31
bits).  However, displaying only works for the characters present in the
selected font.

Useful commands:
- "ga" shows the decimal, hexadecimal and octal value of the character under
  the cursor.  If there are composing characters these are shown too.  (If the
  message is truncated, use ":messages").
- "g8" shows the bytes used in a UTF-8 character, also the composing
  characters, as hex numbers.
- ":set fileencodings=" forces using UTF-8 for all files.  The
  default is to automatically detect the encoding of a file.


STARTING VIM

You might want to select the font used for the menus.  Unfortunately this
doesn't always work.  See the system specific remarks below, and 'langmenu'.


USING UTF-8 IN X-Windows				*utf-8-in-xwindows*

You need to specify a font to be used.  For double-wide characters another
font is required, which is exactly twice as wide.  There are three ways to do
this:

1. Set 'guifont' and let Vim find a matching 'guifontwide'
2. Set 'guifont' and 'guifontwide'

See the documentation for each option for details.  Example: >

   :set guifont=-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso10646-1

You might also want to set the font used for the menus.  This only works for
Motif.  Use the ":hi Menu font={fontname}" command for this. |:highlight|


TYPING UTF-8						*utf-8-typing*

If you are using X-Windows, you should find an input method that supports
UTF-8.

If your system does not provide support for typing UTF-8, you can use the
'keymap' feature.  This allows writing a keymap file, which defines a UTF-8
character as a sequence of ASCII characters.  See |mbyte-keymap|.

If everything else fails, you can type any character as four hex bytes: >

	CTRL-V u 1234

"1234" is interpreted as a hex number.  You must type four characters, prepend
a zero if necessary.


COMMAND ARGUMENTS					*utf-8-char-arg*

Commands like |f|, |F|, |t| and |r| take an argument of one character.  For
UTF-8 this argument may include one or two composing characters.  These need
to be produced together with the base character, Vim doesn't wait for the next
character to be typed to find out if it is a composing character or not.
Using 'keymap' or |:lmap| is a nice way to type these characters.

The commands that search for a character in a line handle composing characters
as follows.  When searching for a character without a composing character,
this will find matches in the text with or without composing characters.  When
searching for a character with a composing character, this will only find
matches with that composing character.  It was implemented this way, because
not everybody is able to type a composing character.


==============================================================================
Overview of options					*mbyte-options*

These options are relevant for editing multibyte files.

'fileencoding'	Encoding of a file.  When it's different from "utf-8"
		conversion is done when reading or writing the file.

'fileencodings'	List of possible encodings of a file.  When opening a file
		these will be tried and the first one that doesn't cause an
		error is used for 'fileencoding'.

'charconvert'	Expression used to convert files from one encoding to another.

'formatoptions' The 'm' flag can be included to have formatting break a line
		at a multibyte character of 256 or higher.  Thus is useful for
		languages where a sequence of characters can be broken
		anywhere.

'keymap'	Specify the name of a keyboard mapping.

==============================================================================

Contributions specifically for the multibyte features by:
	Chi-Deok Hwang <hwang@mizi.co.kr>
	SungHyun Nam <goweol@gmail.com>
	K.Nagano <nagano@atese.advantest.co.jp>
	Taro Muraoka  <koron@tka.att.ne.jp>
	Yasuhiro Matsumoto <mattn@mail.goo.ne.jp>

 vim:tw=78:ts=8:noet:ft=help:norl: