robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1*mbyte.txt* Nvim 2 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 17 Type |gO| to see the table of contents. 18 19============================================================================== 20Getting started *mbyte-first* 21 22This is a summary of the multibyte features in Nvim. 23 24 25LOCALE 26 27First of all, you must make sure your current locale is set correctly. If 28your system has been installed to use the language, it probably works right 29away. If not, you can often make it work by setting the $LANG environment 30variable in your shell: > 31 32 setenv LANG ja_JP.EUC 33 34Unfortunately, the name of the locale depends on your system. Japanese might 35also be called "ja_JP.EUCjp" or just "ja". To see what is currently used: > 36 37 :language 38 39To change the locale inside Vim use: > 40 41 :language ja_JP.EUC 42 43Vim will give an error message if this doesn't work. This is a good way to 44experiment and find the locale name you want to use. But it's always better 45to set the locale in the shell, so that it is used right from the start. 46 47See |mbyte-locale| for details. 48 49 50ENCODING 51 52Nvim always uses UTF-8 internally. Thus 'encoding' is always set to "utf-8" 53and cannot be changed. 54 55All the text that is used inside Vim will be in UTF-8. Not only the text in 56the buffers, but also in registers, variables, etc. 57 58You can edit files in different encodings than UTF-8. Nvim will convert the 59file when you read it and convert it back when you write it. 60See 'fileencoding', 'fileencodings' and |++enc|. 61 62 63DISPLAY AND FONTS 64 65If you are working in a terminal (emulator) you must make sure it accepts 66UTF-8, the encoding which Vim is working with. Otherwise only ASCII can 67be displayed and edited correctly. 68 69For the GUI you must select fonts that work with UTF-8. You can set 'guifont' 70and 'guifontwide'. 'guifont' is used for the single-width characters, 71'guifontwide' for the double-width characters. Thus the 'guifontwide' font 72must be exactly twice as wide as 'guifont'. Example for UTF-8: > 73 74 :set guifont=-misc-fixed-medium-r-normal-*-18-120-100-100-c-90-iso10646-1 75 :set guifontwide=-misc-fixed-medium-r-normal-*-18-120-100-100-c-180-iso10646-1 76 77You can also set 'guifont' alone, the Nvim GUI will try to find a matching 78'guifontwide' for you. 79 80 81INPUT 82 83There are several ways to enter multibyte characters: 84- Your system IME can be used. 85- Keymaps can be used. See |mbyte-keymap|. 86 87The options 'iminsert', 'imsearch' and 'imcmdline' can be used to choose 88the different input methods or disable them temporarily. 89 90============================================================================== 91Locale *mbyte-locale* 92 93The easiest setup is when your whole system uses the locale you want to work 94in. But it's also possible to set the locale for one shell you are working 95in, or just use a certain locale inside Vim. 96 97 98WHAT IS A LOCALE? *locale* 99 100There are many languages in the world. And there are different cultures and 101environments at least as many as the number of languages. A linguistic 102environment corresponding to an area is called "locale". This includes 103information about the used language, the charset, collating order for sorting, 104date format, currency format and so on. For Vim only the language and charset 105really matter. 106 107You can only use a locale if your system has support for it. Some systems 108have only a few locales, especially in the USA. The language which you want 109to use may not be on your system. In that case you might be able to install 110it as an extra package. Check your system documentation for how to do that. 111 112The location in which the locales are installed varies from system to system. 113For example, "/usr/share/locale" or "/usr/lib/locale". See your system's 114setlocale() man page. 115 116Looking in these directories will show you the exact name of each locale. 117Mostly upper/lowercase matters, thus "ja_JP.EUC" and "ja_jp.euc" are 118different. Some systems have a locale.alias file, which allows translation 119from a short name like "nl" to the full name "nl_NL.ISO_8859-1". 120 121Note that X-windows has its own locale stuff. And unfortunately uses locale 122names different from what is used elsewhere. This is confusing! For Vim it 123matters what the setlocale() function uses, which is generally NOT the 124X-windows stuff. You might have to do some experiments to find out what 125really works. 126 127 *locale-name* 128The (simplified) format of |locale| name is: 129 130 language 131or language_territory 132or language_territory.codeset 133 134Territory means the country (or part of it), codeset means the |charset|. For 135example, the locale name "ja_JP.eucJP" means: 136 ja the language is Japanese 137 JP the country is Japan 138 eucJP the codeset is EUC-JP 139But it also could be "ja", "ja_JP.EUC", "ja_JP.ujis", etc. And unfortunately, 140the locale name for a specific language, territory and codeset is not unified 141and depends on your system. 142 143Examples of locale name: 144 charset language locale name ~ 145 GB2312 Chinese (simplified) zh_CN.EUC, zh_CN.GB2312 146 Big5 Chinese (traditional) zh_TW.BIG5, zh_TW.Big5 147 CNS-11643 Chinese (traditional) zh_TW 148 EUC-JP Japanese ja, ja_JP.EUC, ja_JP.ujis, ja_JP.eucJP 149 Shift_JIS Japanese ja_JP.SJIS, ja_JP.Shift_JIS 150 EUC-KR Korean ko, ko_KR.EUC 151 152 153USING A LOCALE 154 155To start using a locale for the whole system, see the documentation of your 156system. Mostly you need to set it in a configuration file in "/etc". 157 158To use a locale in a shell, set the $LANG environment value. When you want to 159use Korean and the |locale| name is "ko", do this: 160 161 sh: export LANG=ko 162 csh: setenv LANG ko 163 164You can put this in your ~/.profile or ~/.cshrc file to always use it. 165 166To use a locale in Vim only, use the |:language| command: > 167 168 :language ko 169 170Put this in your |init.vim| file to use it always. 171 172Or specify $LANG when starting Vim: 173 174 sh: LANG=ko vim {vim-arguments} 175 csh: env LANG=ko vim {vim-arguments} 176 177You could make a small shell script for this. 178 179============================================================================== 180Encoding *mbyte-encoding* 181 182UTF-8 is always used internally to encode characters. This applies to all the 183places where text is used, including buffers (files loaded into memory), 184registers and variables. 185 186 *charset* *codeset* 187Charset is another name for encoding. There are subtle differences, but these 188don't matter when using Vim. "codeset" is another similar name. 189 190Each character is encoded as one or more bytes. When all characters are 191encoded with one byte, we call this a single-byte encoding. The most often 192used one is called "latin1". This limits the number of characters to 256. 193Some of these are control characters, thus even fewer can be used for text. 194 195When some characters use two or more bytes, we call this a multibyte 196encoding. This allows using much more than 256 characters, which is required 197for most East Asian languages. 198 199Most multibyte encodings use one byte for the first 127 characters. These 200are equal to ASCII, which makes it easy to exchange plain-ASCII text, no 201matter what language is used. Thus you might see the right text even when the 202encoding was set wrong. 203 204 *encoding-names* 205Vim can edit files in different character encodings. There are three major groups: 206 2071 8bit Single-byte encodings, 256 different characters. Mostly used 208 in USA and Europe. Example: ISO-8859-1 (Latin1). All 209 characters occupy one screen cell only. 210 2112 2byte Double-byte encodings, over 10000 different characters. 212 Mostly used in Asian countries. Example: euc-kr (Korean) 213 The number of screen cells is equal to the number of bytes 214 (except for euc-jp when the first byte is 0x8e). 215 216u Unicode Universal encoding, can replace all others. ISO 10646. 217 Millions of different characters. Example: UTF-8. The 218 relation between bytes and screen cells is complex. 219 220Only UTF-8 is used by Vim internally. But files in other 221encodings can be edited by using conversion, see 'fileencoding'. 222 223Recognized 'fileencoding' values include: *encoding-values* 2241 latin1 8-bit characters (ISO 8859-1, also used for cp1252) 2251 iso-8859-n ISO_8859 variant (n = 2 to 15) 2261 koi8-r Russian 2271 koi8-u Ukrainian 2281 macroman MacRoman (Macintosh encoding) 2291 8bit-{name} any 8-bit encoding (Vim specific name) 2301 cp437 similar to iso-8859-1 2311 cp737 similar to iso-8859-7 2321 cp775 Baltic 2331 cp850 similar to iso-8859-4 2341 cp852 similar to iso-8859-1 2351 cp855 similar to iso-8859-2 2361 cp857 similar to iso-8859-5 2371 cp860 similar to iso-8859-9 2381 cp861 similar to iso-8859-1 2391 cp862 similar to iso-8859-1 2401 cp863 similar to iso-8859-8 2411 cp865 similar to iso-8859-1 2421 cp866 similar to iso-8859-5 2431 cp869 similar to iso-8859-7 2441 cp874 Thai 2451 cp1250 Czech, Polish, etc. 2461 cp1251 Cyrillic 2471 cp1253 Greek 2481 cp1254 Turkish 2491 cp1255 Hebrew 2501 cp1256 Arabic 2511 cp1257 Baltic 2521 cp1258 Vietnamese 2531 cp{number} MS-Windows: any installed single-byte codepage 2542 cp932 Japanese (Windows only) 2552 euc-jp Japanese 2562 sjis Japanese 2572 cp949 Korean 2582 euc-kr Korean 2592 cp936 simplified Chinese (Windows only) 2602 euc-cn simplified Chinese 2612 cp950 traditional Chinese (alias for big5) 2622 big5 traditional Chinese (alias for cp950) 2632 euc-tw traditional Chinese 2642 2byte-{name} any double-byte encoding (Vim-specific name) 2652 cp{number} MS-Windows: any installed double-byte codepage 266u utf-8 32 bit UTF-8 encoded Unicode (ISO/IEC 10646-1) 267u ucs-2 16 bit UCS-2 encoded Unicode (ISO/IEC 10646-1) 268u ucs-2le like ucs-2, little endian 269u utf-16 ucs-2 extended with double-words for more characters 270u utf-16le like utf-16, little endian 271u ucs-4 32 bit UCS-4 encoded Unicode (ISO/IEC 10646-1) 272u ucs-4le like ucs-4, little endian 273 274The {name} can be any encoding name that your system supports. It is passed 275to iconv() to convert between UTF-8 and the encoding of the file. 276For MS-Windows "cp{number}" means using codepage {number}. 277Examples: > 278 :set fileencoding=8bit-cp1252 279 :set fileencoding=2byte-cp932 280 281The MS-Windows codepage 1252 is very similar to latin1. For practical reasons 282the same encoding is used and it's called latin1. 283 284Several aliases can be used, they are translated to one of the names above. 285Incomplete list: 286 2871 ansi same as latin1 (obsolete, for backward compatibility) 2882 japan Japanese: "euc-jp" 2892 korea Korean: "euc-kr" 2902 prc simplified Chinese: "euc-cn" 2912 chinese same as "prc" 2922 taiwan traditional Chinese: "euc-tw" 293u utf8 same as utf-8 294u unicode same as ucs-2 295u ucs2be same as ucs-2 (big endian) 296u ucs-2be same as ucs-2 (big endian) 297u ucs-4be same as ucs-4 (big endian) 298u utf-32 same as ucs-4 299u utf-32le same as ucs-4le 300 default the encoding of the current locale. 301 302For the UCS codes the byte order matters. This is tricky, use UTF-8 whenever 303you can. The default is to use big-endian (most significant byte comes 304first): 305 name bytes char ~ 306 ucs-2 11 22 1122 307 ucs-2le 22 11 1122 308 ucs-4 11 22 33 44 11223344 309 ucs-4le 44 33 22 11 11223344 310 311On MS-Windows systems you often want to use "ucs-2le", because it uses little 312endian UCS-2. 313 314There are a few encodings which are similar, but not exactly the same. Vim 315treats them as if they were different encodings, so that conversion will be 316done when needed. You might want to use the similar name to avoid conversion 317or when conversion is not possible: 318 319 cp932, shift-jis, sjis 320 cp936, euc-cn 321 322CONVERSION *charset-conversion* 323 324Vim will automatically convert from one to another encoding in several places: 325- When reading a file and 'fileencoding' is different from "utf-8" 326- When writing a file and 'fileencoding' is different from "utf-8" 327- When displaying messages and the encoding used for LC_MESSAGES differs from 328 "utf-8" (requires a gettext version that supports this). 329- When reading a Vim script where |:scriptencoding| is different from 330 "utf-8". 331Most of these require iconv. Conversion for reading and writing files may 332also be specified with the 'charconvert' option. 333 334Useful utilities for converting the charset: 335 All: iconv 336 GNU iconv can convert most encodings. Unicode is used as the 337 intermediate encoding, which allows conversion from and to all other 338 encodings. See https://directory.fsf.org/wiki/Libiconv. 339 340 341 *mbyte-conversion* 342When reading and writing files in an encoding different from "utf-8", 343conversion needs to be done. These conversions are supported: 344- All conversions between Latin-1 (ISO-8859-1), UTF-8, UCS-2 and UCS-4 are 345 handled internally. 346- For MS-Windows, conversion from and 347 to any codepage should work. 348- Conversion specified with 'charconvert' 349- Conversion with the iconv library, if it is available. 350 Old versions of GNU iconv() may cause the conversion to fail (they 351 request a very large buffer, more than Vim is willing to provide). 352 Try getting another iconv() implementation. 353 354============================================================================== 355Input with a keymap *mbyte-keymap* 356 357When the keyboard doesn't produce the characters you want to enter in your 358text, you can use the 'keymap' option. This will translate one or more 359(English) characters to another (non-English) character. This only happens 360when typing text, not when typing Vim commands. This avoids having to switch 361between two keyboard settings. 362 363The value of the 'keymap' option specifies a keymap file to use. The name of 364this file is one of these two: 365 366 keymap/{keymap}_utf-8.vim 367 keymap/{keymap}.vim 368 369Here {keymap} is the value of the 'keymap' option. 370The file name with "utf-8" included is tried first. 371 372'runtimepath' is used to find these files. To see an overview of all 373available keymap files, use this: > 374 :echo globpath(&rtp, "keymap/*.vim") 375 376In Insert and Command-line mode you can use CTRL-^ to toggle between using the 377keyboard map or not. |i_CTRL-^| |c_CTRL-^| 378This flag is remembered for Insert mode with the 'iminsert' option. When 379leaving and entering Insert mode the previous value is used. The same value 380is also used for commands that take a single character argument, like |f| and 381|r|. 382For Command-line mode the flag is NOT remembered. You are expected to type an 383Ex command first, which is ASCII. 384For typing search patterns the 'imsearch' option is used. It can be set to 385use the same value as for 'iminsert'. 386 *lCursor* 387It is possible to give the GUI cursor another color when the language mappings 388are being used. This is disabled by default, to avoid that the cursor becomes 389invisible when you use a non-standard background color. Here is an example to 390use a brightly colored cursor: > 391 :highlight Cursor guifg=NONE guibg=Green 392 :highlight lCursor guifg=NONE guibg=Cyan 393< 394 *keymap-file-format* *:loadk* *:loadkeymap* *E105* *E791* 395The keymap file looks something like this: > 396 397 " Maintainer: name <email@address> 398 " Last Changed: 2001 Jan 1 399 400 let b:keymap_name = "short" 401 402 loadkeymap 403 a A 404 b B comment 405 406The lines starting with a " are comments and will be ignored. Blank lines are 407also ignored. The lines with the mappings may have a comment after the useful 408text. 409 410The "b:keymap_name" can be set to a short name, which will be shown in the 411status line. The idea is that this takes less room than the value of 412'keymap', which might be long to distinguish between different languages, 413keyboards and encodings. 414 415The actual mappings are in the lines below "loadkeymap". In the example "a" 416is mapped to "A" and "b" to "B". Thus the first item is mapped to the second 417item. This is done for each line, until the end of the file. 418These items are exactly the same as what can be used in a |:lmap| command, 419using "<buffer>" to make the mappings local to the buffer. 420You can check the result with this command: > 421 :lmap 422The two items must be separated by white space. You cannot include white 423space inside an item, use the special names "<Tab>" and "<Space>" instead. 424The length of the two items together must not exceed 200 bytes. 425 426It's possible to have more than one character in the first column. This works 427like a dead key. Example: > 428 'a á 429Since Vim doesn't know if the next character after a quote is really an "a", 430it will wait for the next character. To be able to insert a single quote, 431also add this line: > 432 '' ' 433Since the mapping is defined with |:lmap| the resulting quote will not be 434used for the start of another character defined in the 'keymap'. 435It can be used in a standard |:imap| mapping. 436The "accents" keymap uses this. *keymap-accents* 437 438The first column can also be in |<>| form: 439 <C-c> Ctrl-C 440 <A-c> Alt-c 441 <A-C> Alt-C 442Note that the Alt mappings may not work, depending on your keyboard and 443terminal. 444 445Although it's possible to have more than one character in the second column, 446this is unusual. But you can use various ways to specify the character: > 447 A a literal character 448 A <char-97> decimal value 449 A <char-0x61> hexadecimal value 450 A <char-0141> octal value 451 x <Space> special key name 452 453The characters are assumed to be encoded in UTF-8. 454It's possible to use ":scriptencoding" when all characters are given 455literally. That doesn't work when using the <char-> construct, because the 456conversion is done on the keymap file, not on the resulting character. 457 458The lines after "loadkeymap" are interpreted with 'cpoptions' set to "C". 459This means that continuation lines are not used and a backslash has a special 460meaning in the mappings. Examples: > 461 462 " a comment line 463 \" x maps " to x 464 \\ y maps \ to y 465 466If you write a keymap file that will be useful for others, consider submitting 467it to the Vim maintainer for inclusion in the distribution: 468<maintainer@vim.org> 469 470 471HEBREW KEYMAP *keymap-hebrew* 472 473This file explains what characters are available in UTF-8 and CP1255 474encodings, and what the keymaps are to get those characters: 475 476glyph encoding keymap ~ 477Char UTF-8 cp1255 hebrew hebrewp name ~ 478א 0x5d0 0xe0 t a alef 479ב 0x5d1 0xe1 c b bet 480ג 0x5d2 0xe2 d g gimel 481ד 0x5d3 0xe3 s d dalet 482ה 0x5d4 0xe4 v h he 483ו 0x5d5 0xe5 u v vav 484ז 0x5d6 0xe6 z z zayin 485ח 0x5d7 0xe7 j j het 486ט 0x5d8 0xe8 y T tet 487י 0x5d9 0xe9 h y yod 488ך 0x5da 0xea l K kaf sofit 489כ 0x5db 0xeb f k kaf 490ל 0x5dc 0xec k l lamed 491ם 0x5dd 0xed o M mem sofit 492מ 0x5de 0xee n m mem 493ן 0x5df 0xef i N nun sofit 494נ 0x5e0 0xf0 b n nun 495ס 0x5e1 0xf1 x s samech 496ע 0x5e2 0xf2 g u ayin 497ף 0x5e3 0xf3 ; P pe sofit 498פ 0x5e4 0xf4 p p pe 499ץ 0x5e5 0xf5 . X tsadi sofit 500צ 0x5e6 0xf6 m x tsadi 501ק 0x5e7 0xf7 e q qof 502ר 0x5e8 0xf8 r r resh 503ש 0x5e9 0xf9 a w shin 504ת 0x5ea 0xfa , t tav 505 506Vowel marks and special punctuation: 507הְ 0x5b0 0xc0 A: A: sheva 508הֱ 0x5b1 0xc1 HE HE hataf segol 509הֲ 0x5b2 0xc2 HA HA hataf patah 510הֳ 0x5b3 0xc3 HO HO hataf qamats 511הִ 0x5b4 0xc4 I I hiriq 512הֵ 0x5b5 0xc5 AY AY tsere 513הֶ 0x5b6 0xc6 E E segol 514הַ 0x5b7 0xc7 AA AA patah 515הָ 0x5b8 0xc8 AO AO qamats 516הֹ 0x5b9 0xc9 O O holam 517הֻ 0x5bb 0xcb U U qubuts 518כּ 0x5bc 0xcc D D dagesh 519הֽ 0x5bd 0xcd ]T ]T meteg 520ה־ 0x5be 0xce ]Q ]Q maqaf 521בֿ 0x5bf 0xcf ]R ]R rafe 522ב׀ 0x5c0 0xd0 ]p ]p paseq 523שׁ 0x5c1 0xd1 SR SR shin-dot 524שׂ 0x5c2 0xd2 SL SL sin-dot 525׃ 0x5c3 0xd3 ]P ]P sof-pasuq 526װ 0x5f0 0xd4 VV VV double-vav 527ױ 0x5f1 0xd5 VY VY vav-yod 528ײ 0x5f2 0xd6 YY YY yod-yod 529 530The following are only available in UTF-8 531 532Cantillation marks: 533glyph 534Char UTF-8 hebrew name 535ב֑ 0x591 C: etnahta 536ב֒ 0x592 Cs segol 537ב֓ 0x593 CS shalshelet 538ב֔ 0x594 Cz zaqef qatan 539ב֕ 0x595 CZ zaqef gadol 540ב֖ 0x596 Ct tipeha 541ב֗ 0x597 Cr revia 542ב֘ 0x598 Cq zarqa 543ב֙ 0x599 Cp pashta 544ב֚ 0x59a C! yetiv 545ב֛ 0x59b Cv tevir 546ב֜ 0x59c Cg geresh 547ב֝ 0x59d C* geresh qadim 548ב֞ 0x59e CG gershayim 549ב֟ 0x59f CP qarnei-parah 550ב֪ 0x5aa Cy yerach-ben-yomo 551ב֫ 0x5ab Co ole 552ב֬ 0x5ac Ci iluy 553ב֭ 0x5ad Cd dehi 554ב֮ 0x5ae Cn zinor 555ב֯ 0x5af CC masora circle 556 557Combining forms: 558ﬠ 0xfb20 X` Alternative ayin 559ﬡ 0xfb21 X' Alternative alef 560ﬢ 0xfb22 X-d Alternative dalet 561ﬣ 0xfb23 X-h Alternative he 562ﬤ 0xfb24 X-k Alternative kaf 563ﬥ 0xfb25 X-l Alternative lamed 564ﬦ 0xfb26 X-m Alternative mem-sofit 565ﬧ 0xfb27 X-r Alternative resh 566ﬨ 0xfb28 X-t Alternative tav 567﬩ 0xfb29 X-+ Alternative plus 568שׁ 0xfb2a XW shin+shin-dot 569שׂ 0xfb2b Xw shin+sin-dot 570שּׁ 0xfb2c X..W shin+shin-dot+dagesh 571שּׂ 0xfb2d X..w shin+sin-dot+dagesh 572אַ 0xfb2e XA alef+patah 573אָ 0xfb2f XO alef+qamats 574אּ 0xfb30 XI alef+hiriq (mapiq) 575בּ 0xfb31 X.b bet+dagesh 576גּ 0xfb32 X.g gimel+dagesh 577דּ 0xfb33 X.d dalet+dagesh 578הּ 0xfb34 X.h he+dagesh 579וּ 0xfb35 Xu vav+dagesh 580זּ 0xfb36 X.z zayin+dagesh 581טּ 0xfb38 X.T tet+dagesh 582יּ 0xfb39 X.y yud+dagesh 583ךּ 0xfb3a X.K kaf sofit+dagesh 584כּ 0xfb3b X.k kaf+dagesh 585לּ 0xfb3c X.l lamed+dagesh 586מּ 0xfb3e X.m mem+dagesh 587נּ 0xfb40 X.n nun+dagesh 588סּ 0xfb41 X.s samech+dagesh 589ףּ 0xfb43 X.P pe sofit+dagesh 590פּ 0xfb44 X.p pe+dagesh 591צּ 0xfb46 X.x tsadi+dagesh 592קּ 0xfb47 X.q qof+dagesh 593רּ 0xfb48 X.r resh+dagesh 594שּ 0xfb49 X.w shin+dagesh 595תּ 0xfb4a X.t tav+dagesh 596וֹ 0xfb4b Xo vav+holam 597בֿ 0xfb4c XRb bet+rafe 598כֿ 0xfb4d XRk kaf+rafe 599פֿ 0xfb4e XRp pe+rafe 600ﭏ 0xfb4f Xal alef-lamed 601 602============================================================================== 603Using UTF-8 *mbyte-utf8* *UTF-8* *utf-8* *utf8* 604 *Unicode* *unicode* 605The Unicode character set was designed to include all characters from other 606character sets. Therefore it is possible to write text in (almost) any 607language using Unicode. And it's mostly possible to mix these languages in 608one file, which is impossible with other encodings. 609 610Unicode can be encoded in several ways. The most popular one is UTF-8, which 611uses one or more bytes for each character and is backwards compatible with 612ASCII. On MS-Windows UTF-16 is also used (previously UCS-2), which uses 61316-bit words. Nvim supports all of these encodings, but always uses UTF-8 614internally. 615 616Nvim supports double-width characters; works best with 'guifontwide'. When 617using only 'guifont' the wide characters are drawn in the normal width and 618a space to fill the gap. 619 620EMOJI *emoji* 621 622You can list emoji characters using this script: >vim 623 :source $VIMRUNTIME/scripts/emoji_list.lua 624< 625 *bom-bytes* 626When reading a file a BOM (Byte Order Mark) can be used to recognize the 627Unicode encoding: 628 EF BB BF UTF-8 629 FE FF UTF-16 big endian 630 FF FE UTF-16 little endian 631 00 00 FE FF UTF-32 big endian 632 FF FE 00 00 UTF-32 little endian 633 634UTF-8 is the recommended encoding. Note that it's difficult to tell UTF-16 635and UTF-32 apart. UTF-16 is often used on MS-Windows, UTF-32 is not 636widespread as file format. 637 638 639 *mbyte-combining* *mbyte-composing* 640A composing or combining character is used to change the meaning of the 641character before it. The combining characters are drawn on top of the 642preceding character. 643 644Nvim largely follows the definition of extended grapheme clusters in UAX#29 645in the Unicode standard, with some modifications: An ascii char will always 646start a new cluster. In addition 'arabicshape' enables the combining of some 647arabic letters, when they are shaped to be displayed together in a single cell. 648 649Too big combined characters cannot be displayed, but they can still be 650inspected using the |g8| and |ga| commands described below. 651When editing text a composing character is mostly considered part of the 652preceding character. For example "x" will delete a character and its 653following composing characters by default. 654If the 'delcombine' option is on, then pressing 'x' will delete the combining 655characters, one at a time, then the base character. But when inserting, you 656type the first character and the following composing characters separately, 657after which they will be joined. The "r" command will not allow you to type a 658combining character, because it doesn't know one is coming. Use "R" instead. 659 660Bytes which are not part of a valid UTF-8 byte sequence are handled like a 661single character and displayed as <xx>, where "xx" is the hex value of the 662byte. 663 664Overlong sequences are not handled specially and displayed like a valid 665character. However, search patterns may not match on an overlong sequence. 666(an overlong sequence is where more bytes are used than required for the 667character.) An exception is NUL (zero) which is displayed as "<00>". 668 669In the file and buffer the full range of Unicode characters can be used (31 670bits). However, displaying only works for the characters present in the 671selected font. 672 673Useful commands: 674- "ga" shows the decimal, hexadecimal and octal value of the character under 675 the cursor. If there are composing characters these are shown too. (If the 676 message is truncated, use ":messages"). 677- "g8" shows the bytes used in a UTF-8 character, also the composing 678 characters, as hex numbers. 679- ":set fileencodings=" forces using UTF-8 for all files. The 680 default is to automatically detect the encoding of a file. 681 682 683STARTING VIM 684 685You might want to select the font used for the menus. Unfortunately this 686doesn't always work. See the system specific remarks below, and 'langmenu'. 687 688 689USING UTF-8 IN X-WINDOWS *utf-8-in-xwindows* 690 691You need to specify a font to be used. For double-wide characters another 692font is required, which is exactly twice as wide. There are two ways to do 693this: 694 6951. Set 'guifont' and let Nvim find a matching 'guifontwide' 6962. Set 'guifont' and 'guifontwide' 697 698See the documentation for each option for details. Example: > 699 700 :set guifont=-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso10646-1 701 702You might also want to set the font used for the menus. This only works for 703Motif. Use the ":hi Menu font={fontname}" command for this. |:highlight| 704 705 706TYPING UTF-8 *utf-8-typing* 707 708If you are using X-Windows, you should find an input method that supports 709UTF-8. 710 711If your system does not provide support for typing UTF-8, you can use the 712'keymap' feature. This allows writing a keymap file, which defines a UTF-8 713character as a sequence of ASCII characters. See |mbyte-keymap|. 714 715If everything else fails, you can type any character as four hex bytes: > 716 717 CTRL-V u 1234 718 719"1234" is interpreted as a hex number. You must type four characters, prepend 720a zero if necessary. 721 722 723COMMAND ARGUMENTS *utf-8-char-arg* 724 725Commands like |f|, |F|, |t| and |r| take an argument of one character. For 726UTF-8 this argument may include one or two composing characters. These need 727to be produced together with the base character, Nvim doesn't wait for the next 728character to be typed to find out if it is a composing character or not. 729Using 'keymap' or |:lmap| is a nice way to type these characters. 730 731The commands that search for a character in a line handle composing characters 732as follows. When searching for a character without a composing character, 733this will find matches in the text with or without composing characters. When 734searching for a character with a composing character, this will only find 735matches with that composing character. It was implemented this way, because 736not everybody is able to type a composing character. 737 738============================================================================== 739Overview of options *mbyte-options* 740 741These options are relevant for editing multibyte files. 742 743'fileencoding' Encoding of a file. When it's different from "utf-8" 744 conversion is done when reading or writing the file. 745 746'fileencodings' List of possible encodings of a file. When opening a file 747 these will be tried and the first one that doesn't cause an 748 error is used for 'fileencoding'. 749 750'charconvert' Expression used to convert files from one encoding to another. 751 752'formatoptions' The 'm' flag can be included to have formatting break a line 753 at a multibyte character of 256 or higher. Thus is useful for 754 languages where a sequence of characters can be broken 755 anywhere. 756 757'keymap' Specify the name of a keyboard mapping. 758 759============================================================================== 760 761Contributions specifically for the multibyte features by: 762 Chi-Deok Hwang <hwang@mizi.co.kr> 763 SungHyun Nam <goweol@gmail.com> 764 K.Nagano <nagano@atese.advantest.co.jp> 765 Taro Muraoka <koron@tka.att.ne.jp> 766 Yasuhiro Matsumoto <mattn@mail.goo.ne.jp> 767 768 vim:tw=78:ts=8:noet:ft=help:norl: