Home Explore Blog CI



neovim

5th chunk of `runtime/doc/mbyte.txt`
d91d9fc5e82632a44d459e1a6554ea62b97a07737fa4ead00000000100000fa1
 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 https://directory.fsf.org/wiki/Libiconv.


							*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 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"

Title: Character Conversion and Keymap Usage in Vim
Summary
This section explains character conversion in Vim, covering internal handling of Latin-1, UTF-8, UCS-2, and UCS-4, as well as conversions on MS-Windows and through 'charconvert' and iconv. It also describes the 'keymap' option for translating characters during text input, detailing keymap file structure, toggling the keyboard map with CTRL-^, and customizing the GUI cursor color when language mappings are in use.