代码拉取完成,页面将自动刷新
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>usr_45 - Vim Documentation</title>
<meta name="Generator" content="Vim/8.0">
<meta name="plugin-version" content="vim8.0">
<meta name="syntax" content="help">
<meta name="settings" content="no_pre,use_css,expand_tabs">
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="jquery.min.js" type="text/javascript"></script>
<script src="mark-current-page.js" type="text/javascript"></script>
</head>
<body>
<header>
<div class="header">
<a href="http://vim-jp.org/">vim-jp</a>
/ <a href="http://vim-jp.org/vimdoc-en/">vimdoc-en</a>
/ usr_45<br />
<a name="top"></a><h1>usr_45 - Vim Documentation</h1>
<a href="index.html">Return to main</a>
<span class="EnglishJapaneseLink">
<span class="CurrentLanguage">English</span>
</span>
</div>
</header>
<nav>
<dl>
<dt>BASIC</dt>
<dd><ul>
<li><a href="quickref.html">quickref</a></li>
<li><a href="sponsor.html">sponsor</a></li>
</ul></dd>
<dt>USER MANUAL</dt>
<dd><ul>
<li><a href="usr_toc.html">usr_toc</a></li>
</ul></dd>
<dt>Getting Started</dt>
<dd><ul>
<li><a href="usr_01.html">usr_01</a></li>
<li><a href="usr_02.html">usr_02</a></li>
<li><a href="usr_03.html">usr_03</a></li>
<li><a href="usr_04.html">usr_04</a></li>
<li><a href="usr_05.html">usr_05</a></li>
<li><a href="usr_06.html">usr_06</a></li>
<li><a href="usr_07.html">usr_07</a></li>
<li><a href="usr_08.html">usr_08</a></li>
<li><a href="usr_09.html">usr_09</a></li>
<li><a href="usr_10.html">usr_10</a></li>
<li><a href="usr_11.html">usr_11</a></li>
<li><a href="usr_12.html">usr_12</a></li>
</ul></dd>
<dt>Editing Effectively</dt>
<dd><ul>
<li><a href="usr_20.html">usr_20</a></li>
<li><a href="usr_21.html">usr_21</a></li>
<li><a href="usr_22.html">usr_22</a></li>
<li><a href="usr_23.html">usr_23</a></li>
<li><a href="usr_24.html">usr_24</a></li>
<li><a href="usr_25.html">usr_25</a></li>
<li><a href="usr_26.html">usr_26</a></li>
<li><a href="usr_27.html">usr_27</a></li>
<li><a href="usr_28.html">usr_28</a></li>
<li><a href="usr_29.html">usr_29</a></li>
<li><a href="usr_30.html">usr_30</a></li>
<li><a href="usr_31.html">usr_31</a></li>
<li><a href="usr_32.html">usr_32</a></li>
</ul></dd>
<dt>Tuning Vim</dt>
<dd><ul>
<li><a href="usr_40.html">usr_40</a></li>
<li><a href="usr_41.html">usr_41</a></li>
<li><a href="usr_42.html">usr_42</a></li>
<li><a href="usr_43.html">usr_43</a></li>
<li><a href="usr_44.html">usr_44</a></li>
<li><a href="usr_45.html">usr_45</a></li>
</ul></dd>
<dt>Making Vim Run</dt>
<dd><ul>
<li><a href="usr_90.html">usr_90</a></li>
</ul></dd>
<dt>General subjects</dt>
<dd><ul>
<li><a href="intro.html">intro</a></li>
<li><a href="index.html">help</a></li>
<li><a href="helphelp.html">helphelp</a></li>
<li><a href="vimindex.html">index</a></li>
<li><a href="tags.html">tags</a></li>
<li><a href="howto.html">howto</a></li>
<li><a href="tips.html">tips</a></li>
<li><a href="message.html">message</a></li>
<li><a href="quotes.html">quotes</a></li>
<li><a href="todo.html">todo</a></li>
<li><a href="debug.html">debug</a></li>
<li><a href="develop.html">develop</a></li>
<li><a href="uganda.html">uganda</a></li>
</ul></dd>
<dt>Basic editing</dt>
<dd><ul>
<li><a href="starting.html">starting</a></li>
<li><a href="editing.html">editing</a></li>
<li><a href="motion.html">motion</a></li>
<li><a href="scroll.html">scroll</a></li>
<li><a href="insert.html">insert</a></li>
<li><a href="change.html">change</a></li>
<li><a href="indent.html">indent</a></li>
<li><a href="undo.html">undo</a></li>
<li><a href="repeat.html">repeat</a></li>
<li><a href="visual.html">visual</a></li>
<li><a href="various.html">various</a></li>
<li><a href="recover.html">recover</a></li>
</ul></dd>
<dt>Advanced editing</dt>
<dd><ul>
<li><a href="cmdline.html">cmdline</a></li>
<li><a href="options.html">options</a></li>
<li><a href="pattern.html">pattern</a></li>
<li><a href="map.html">map</a></li>
<li><a href="tagsrch.html">tagsrch</a></li>
<li><a href="quickfix.html">quickfix</a></li>
<li><a href="windows.html">windows</a></li>
<li><a href="tabpage.html">tabpage</a></li>
<li><a href="syntax.html">syntax</a></li>
<li><a href="spell.html">spell</a></li>
<li><a href="diff.html">diff</a></li>
<li><a href="autocmd.html">autocmd</a></li>
<li><a href="filetype.html">filetype</a></li>
<li><a href="eval.html">eval</a></li>
<li><a href="channel.html">channel</a></li>
<li><a href="fold.html">fold</a></li>
</ul></dd>
<dt>Special issues</dt>
<dd><ul>
<li><a href="print.html">print</a></li>
<li><a href="remote.html">remote</a></li>
<li><a href="term.html">term</a></li>
<li><a href="digraph.html">digraph</a></li>
<li><a href="mbyte.html">mbyte</a></li>
<li><a href="mlang.html">mlang</a></li>
<li><a href="arabic.html">arabic</a></li>
<li><a href="farsi.html">farsi</a></li>
<li><a href="hebrew.html">hebrew</a></li>
<li><a href="russian.html">russian</a></li>
<li><a href="ft_ada.html">ft_ada</a></li>
<li><a href="ft_sql.html">ft_sql</a></li>
<li><a href="hangulin.html">hangulin</a></li>
<li><a href="rileft.html">rileft</a></li>
</ul></dd>
<dt>GUI</dt>
<dd><ul>
<li><a href="gui.html">gui</a></li>
<li><a href="gui_w32.html">gui_w32</a></li>
<li><a href="gui_x11.html">gui_x11</a></li>
</ul></dd>
<dt>Interfaces</dt>
<dd><ul>
<li><a href="if_cscop.html">if_cscop</a></li>
<li><a href="if_lua.html">if_lua</a></li>
<li><a href="if_mzsch.html">if_mzsch</a></li>
<li><a href="if_perl.html">if_perl</a></li>
<li><a href="if_pyth.html">if_pyth</a></li>
<li><a href="if_tcl.html">if_tcl</a></li>
<li><a href="if_ole.html">if_ole</a></li>
<li><a href="if_ruby.html">if_ruby</a></li>
<li><a href="debugger.html">debugger</a></li>
<li><a href="workshop.html">workshop</a></li>
<li><a href="netbeans.html">netbeans</a></li>
<li><a href="sign.html">sign</a></li>
</ul></dd>
<dt>Versions</dt>
<dd><ul>
<li><a href="vi_diff.html">vi_diff</a></li>
<li><a href="version4.html">version4</a></li>
<li><a href="version5.html">version5</a></li>
<li><a href="version6.html">version6</a></li>
<li><a href="version7.html">version7</a></li>
<li><a href="version8.html">version8</a></li>
</ul></dd>
<dt>Remarks about specific systems</dt>
<dd><ul>
<li><a href="os_390.html">os_390</a></li>
<li><a href="os_amiga.html">os_amiga</a></li>
<li><a href="os_beos.html">os_beos</a></li>
<li><a href="os_dos.html">os_dos</a></li>
<li><a href="os_mac.html">os_mac</a></li>
<li><a href="os_mint.html">os_mint</a></li>
<li><a href="os_msdos.html">os_msdos</a></li>
<li><a href="os_os2.html">os_os2</a></li>
<li><a href="os_qnx.html">os_qnx</a></li>
<li><a href="os_risc.html">os_risc</a></li>
<li><a href="os_unix.html">os_unix</a></li>
<li><a href="os_vms.html">os_vms</a></li>
<li><a href="os_win32.html">os_win32</a></li>
</ul></dd>
<dt>Standard plugins</dt>
<dd><ul>
<li><a href="pi_getscript.html">pi_getscript</a></li>
<li><a href="pi_gzip.html">pi_gzip</a></li>
<li><a href="pi_logipat.html">pi_logipat</a></li>
<li><a href="pi_netrw.html">pi_netrw</a></li>
<li><a href="pi_paren.html">pi_paren</a></li>
<li><a href="pi_tar.html">pi_tar</a></li>
<li><a href="pi_vimball.html">pi_vimball</a></li>
<li><a href="pi_zip.html">pi_zip</a></li>
</ul></dd>
<dt>Filetype plugins</dt>
<dd><ul>
<li><a href="pi_spec.html">pi_spec</a></li>
</ul></dd>
<dt>Others</dt>
<dd><ul>
<li><a href="vim_faq.html">vim_faq</a></li>
</ul></dd>
</dl>
</nav>
<article class="Vimdoc VimdocJa">
<div id='vimCodeElement'>
<a class="Constant" href="usr_45.html" name="usr_45.txt">usr_45.txt</a> For <span class="Identifier">Vim version 8.0.</span> Last change: 2008 Nov 15<br>
<br>
VIM USER MANUAL - by Bram Moolenaar<br>
<br>
Select your language<br>
<br>
<br>
The messages in Vim can be given in several languages. This chapter explains<br>
how to change which one is used. Also, the different ways to work with files<br>
in various languages is explained.<br>
<br>
<a class="Identifier" href="usr_45.html#45.1">45.1</a> Language for Messages<br>
<a class="Identifier" href="usr_45.html#45.2">45.2</a> Language for Menus<br>
<a class="Identifier" href="usr_45.html#45.3">45.3</a> Using another encoding<br>
<a class="Identifier" href="usr_45.html#45.4">45.4</a> Editing files with a different encoding<br>
<a class="Identifier" href="usr_45.html#45.5">45.5</a> Entering language text<br>
<br>
Next chapter: <a class="Identifier" href="usr_90.html">usr_90.txt</a> Installing Vim<br>
Previous chapter: <a class="Identifier" href="usr_44.html">usr_44.txt</a> Your own syntax highlighted<br>
Table of contents: <a class="Identifier" href="usr_toc.html">usr_toc.txt</a><br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_45.html#45.1" name="45.1">45.1</a> Language for Messages<br>
<br>
When you start Vim, it checks the environment to find out what language you<br>
are using. Mostly this should work fine, and you get the messages in your<br>
language (if they are available). To see what the current language is, use<br>
this command:<br>
<br>
<div class="helpExample"> :language</div>
<br>
If it replies with "C", this means the default is being used, which is<br>
English.<br>
<br>
<span class="Todo">Note</span>:<br>
Using different languages only works when Vim was compiled to handle<br>
it. To find out if it works, use the ":version" command and check the<br>
output for "+gettext" and "+multi_lang". If they are there, you are<br>
OK. If you see "-gettext" or "-multi_lang" you will have to find<br>
another Vim.<br>
<br>
What if you would like your messages in a different language? There are<br>
several ways. Which one you should use depends on the capabilities of your<br>
system.<br>
The first way is to set the environment to the desired language before<br>
starting Vim. Example for Unix:<br>
<br>
<div class="helpExample"> env LANG=de_DE.ISO_8859-1 vim</div>
<br>
This only works if the language is available on your system. The advantage is<br>
that all the GUI messages and things in libraries will use the right language<br>
as well. A disadvantage is that you must do this before starting Vim. If you<br>
want to change language while Vim is running, you can use the second method:<br>
<br>
<div class="helpExample"> :language fr_FR.ISO_8859-1</div>
<br>
This way you can try out several names for your language. You will get an<br>
error message when it's not supported on your system. You don't get an error<br>
when translated messages are not available. Vim will silently fall back to<br>
using English.<br>
To find out which languages are supported on your system, find the<br>
directory where they are listed. On my system it is "/usr/share/locale". On<br>
some systems it's in "/usr/lib/locale". The manual page for "setlocale"<br>
should give you a hint where it is found on your system.<br>
Be careful to type the name exactly as it should be. Upper and lowercase<br>
matter, and the '-' and '_' characters are easily confused.<br>
<br>
You can also set the language separately for messages, edited text and the<br>
time format. See <a class="Identifier" href="mlang.html#:language">:language</a>.<br>
<br>
<br>
DO-IT-YOURSELF MESSAGE TRANSLATION<br>
<br>
If translated messages are not available for your language, you could write<br>
them yourself. To do this, get the source code for Vim and the GNU gettext<br>
package. After unpacking the sources, instructions can be found in the<br>
directory src/po/README.txt.<br>
It's not too difficult to do the translation. You don't need to be a<br>
programmer. You must know both English and the language you are translating<br>
to, of course.<br>
When you are satisfied with the translation, consider making it available<br>
to others. Upload it at vim-online (<span class="Constant"><a href="http://vim.sf.net">http://vim.sf.net</a></span>) or e-mail it to<br>
the Vim maintainer <maintainer@vim.org>. Or both.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_45.html#45.2" name="45.2">45.2</a> Language for Menus<br>
<br>
The default menus are in English. To be able to use your local language, they<br>
must be translated. Normally this is automatically done for you if the<br>
environment is set for your language, just like with messages. You don't need<br>
to do anything extra for this. But it only works if translations for the<br>
language are available.<br>
Suppose you are in Germany, with the language set to German, but prefer to<br>
use "File" instead of "Datei". You can switch back to using the English menus<br>
this way:<br>
<br>
<div class="helpExample"> :set langmenu=none</div>
<br>
It is also possible to specify a language:<br>
<br>
<div class="helpExample"> :set langmenu=nl_NL.ISO_8859-1</div>
<br>
Like above, differences between "-" and "_" matter. However, upper/lowercase<br>
differences are ignored here.<br>
The <a class="Type" href="options.html#'langmenu'">'langmenu'</a> option must be set before the menus are loaded. Once the<br>
menus have been defined changing <a class="Type" href="options.html#'langmenu'">'langmenu'</a> has no direct effect. Therefore,<br>
put the command to set <a class="Type" href="options.html#'langmenu'">'langmenu'</a> in your vimrc file.<br>
If you really want to switch menu language while running Vim, you can do it<br>
this way:<br>
<br>
<div class="helpExample"> :source $VIMRUNTIME/delmenu.vim<br>
:set langmenu=de_DE.ISO_8859-1<br>
:source $VIMRUNTIME/menu.vim</div>
<br>
There is one drawback: All menus that you defined yourself will be gone. You<br>
will need to redefine them as well.<br>
<br>
<br>
DO-IT-YOURSELF MENU TRANSLATION<br>
<br>
To see which menu translations are available, look in this directory:<br>
<br>
<span class="PreProc">$VIMRUNTIME/lang</span><br>
<br>
The files are called menu_<span class="Special">{language}</span>.vim. If you don't see the language you<br>
want to use, you can do your own translations. The simplest way to do this is<br>
by copying one of the existing language files, and change it.<br>
First find out the name of your language with the ":language" command. Use<br>
this name, but with all letters made lowercase. Then copy the file to your<br>
own runtime directory, as found early in <a class="Type" href="options.html#'runtimepath'">'runtimepath'</a>. For example, for Unix<br>
you would do:<br>
<br>
<div class="helpExample"> :!cp $VIMRUNTIME/lang/menu_ko_kr.euckr.vim ~/.vim/lang/menu_nl_be.iso_8859-1.vim</div>
<br>
You will find hints for the translation in "$VIMRUNTIME/lang/README.txt".<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_45.html#45.3" name="45.3">45.3</a> Using another encoding<br>
<br>
Vim guesses that the files you are going to edit are encoded for your<br>
language. For many European languages this is "latin1". Then each byte is<br>
one character. That means there are 256 different characters possible. For<br>
Asian languages this is not sufficient. These mostly use a double-byte<br>
encoding, providing for over ten thousand possible characters. This still<br>
isn't enough when a text is to contain several different languages. This is<br>
where Unicode comes in. It was designed to include all characters used in<br>
commonly used languages. This is the "Super encoding that replaces all<br>
others". But it isn't used that much yet.<br>
Fortunately, Vim supports these three kinds of encodings. And, with some<br>
restrictions, you can use them even when your environment uses another<br>
language than the text.<br>
Nevertheless, when you only edit files that are in the encoding of your<br>
language, the default should work fine and you don't need to do anything. The<br>
following is only relevant when you want to edit different languages.<br>
<br>
<span class="Todo">Note</span>:<br>
Using different encodings only works when Vim was compiled to handle<br>
it. To find out if it works, use the ":version" command and check the<br>
output for "+multi_byte". If it's there, you are OK. If you see<br>
"-multi_byte" you will have to find another Vim.<br>
<br>
<br>
USING UNICODE IN THE GUI<br>
<br>
The nice thing about Unicode is that other encodings can be converted to it<br>
and back without losing information. When you make Vim use Unicode<br>
internally, you will be able to edit files in any encoding.<br>
Unfortunately, the number of systems supporting Unicode is still limited.<br>
Thus it's unlikely that your language uses it. You need to tell Vim you want<br>
to use Unicode, and how to handle interfacing with the rest of the system.<br>
Let's start with the GUI version of Vim, which is able to display Unicode<br>
characters. This should work:<br>
<br>
<div class="helpExample"> :set encoding=utf-8<br>
:set guifont=-misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1</div>
<br>
The <a class="Type" href="options.html#'encoding'">'encoding'</a> option tells Vim the encoding of the characters that you use.<br>
This applies to the text in buffers (files you are editing), registers, Vim<br>
script files, etc. You can regard <a class="Type" href="options.html#'encoding'">'encoding'</a> as the setting for the internals<br>
of Vim.<br>
This example assumes you have this font on your system. The name in the<br>
example is for the X Window System. This font is in a package that is used to<br>
enhance xterm with Unicode support. If you don't have this font, you might<br>
find it here:<br>
<br>
<span class="Constant"><a href="http://www.cl.cam.ac.uk/~mgk25/download/ucs-fonts.tar.gz">http://www.cl.cam.ac.uk/~mgk25/download/ucs-fonts.tar.gz</a></span> <br>
<br>
For MS-Windows, some fonts have a limited number of Unicode characters. Try<br>
using the "Courier New" font. You can use the Edit/Select Font... menu to<br>
select and try out the fonts available. Only fixed-width fonts can be used<br>
though. Example:<br>
<br>
<div class="helpExample"> :set guifont=courier_new:h12</div>
<br>
If it doesn't work well, try getting a fontpack. If Microsoft didn't move it,<br>
you can find it here:<br>
<br>
<span class="Constant"><a href="http://www.microsoft.com/typography/fonts/default.aspx">http://www.microsoft.com/typography/fonts/default.aspx</a></span> <br>
<br>
Now you have told Vim to use Unicode internally and display text with a<br>
Unicode font. Typed characters still arrive in the encoding of your original<br>
language. This requires converting them to Unicode. Tell Vim the language<br>
from which to convert with the <a class="Type" href="options.html#'termencoding'">'termencoding'</a> option. You can do it like<br>
this:<br>
<br>
<div class="helpExample"> :let &termencoding = &encoding<br>
:set encoding=utf-8</div>
<br>
This assigns the old value of <a class="Type" href="options.html#'encoding'">'encoding'</a> to <a class="Type" href="options.html#'termencoding'">'termencoding'</a> before setting<br>
<a class="Type" href="options.html#'encoding'">'encoding'</a> to utf-8. You will have to try out if this really works for your<br>
setup. It should work especially well when using an input method for an Asian<br>
language, and you want to edit Unicode text.<br>
<br>
<br>
USING UNICODE IN A UNICODE TERMINAL<br>
<br>
There are terminals that support Unicode directly. The standard xterm that<br>
comes with XFree86 is one of them. Let's use that as an example.<br>
First of all, the xterm must have been compiled with Unicode support. See<br>
<a class="Identifier" href="mbyte.html#UTF8-xterm">UTF8-xterm</a> how to check that and how to compile it when needed.<br>
Start the xterm with the "-u8" argument. You might also need so specify a<br>
font. Example:<br>
<br>
<div class="helpExample"> xterm -u8 -fn -misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1</div>
<br>
Now you can run Vim inside this terminal. Set <a class="Type" href="options.html#'encoding'">'encoding'</a> to "utf-8" as<br>
before. That's all.<br>
<br>
<br>
USING UNICODE IN AN ORDINARY TERMINAL<br>
<br>
Suppose you want to work with Unicode files, but don't have a terminal with<br>
Unicode support. You can do this with Vim, although characters that are not<br>
supported by the terminal will not be displayed. The layout of the text<br>
will be preserved. <br>
<br>
<div class="helpExample"> :let &termencoding = &encoding<br>
:set encoding=utf-8</div>
<br>
This is the same as what was used for the GUI. But it works differently: Vim<br>
will convert the displayed text before sending it to the terminal. That<br>
avoids that the display is messed up with strange characters.<br>
For this to work the conversion between <a class="Type" href="options.html#'termencoding'">'termencoding'</a> and <a class="Type" href="options.html#'encoding'">'encoding'</a> must<br>
be possible. Vim will convert from latin1 to Unicode, thus that always works.<br>
For other conversions the <a class="Identifier" href="various.html#+iconv">+iconv</a> feature is required.<br>
Try editing a file with Unicode characters in it. You will notice that Vim<br>
will put a question mark (or underscore or some other character) in places<br>
where a character should be that the terminal can't display. Move the cursor<br>
to a question mark and use this command:<br>
<br>
<div class="helpExample"> ga</div>
<br>
Vim will display a line with the code of the character. This gives you a hint<br>
about what character it is. You can look it up in a Unicode table. You could<br>
actually view a file that way, if you have lots of time at hand.<br>
<br>
<span class="Todo">Note</span>:<br>
Since <a class="Type" href="options.html#'encoding'">'encoding'</a> is used for all text inside Vim, changing it makes<br>
all non-ASCII text invalid. You will notice this when using registers<br>
and the <a class="Type" href="options.html#'viminfo'">'viminfo'</a> file (e.g., a remembered search pattern). It's<br>
recommended to set <a class="Type" href="options.html#'encoding'">'encoding'</a> in your vimrc file, and leave it alone.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_45.html#45.4" name="45.4">45.4</a> Editing files with a different encoding<br>
<br>
Suppose you have setup Vim to use Unicode, and you want to edit a file that is<br>
in 16-bit Unicode. Sounds simple, right? Well, Vim actually uses utf-8<br>
encoding internally, thus the 16-bit encoding must be converted, since there<br>
is a difference between the character set (Unicode) and the encoding (utf-8 or<br>
16-bit).<br>
Vim will try to detect what kind of file you are editing. It uses the<br>
encoding names in the <a class="Type" href="options.html#'fileencodings'">'fileencodings'</a> option. When using Unicode, the default<br>
value is: "ucs-bom,utf-8,latin1". This means that Vim checks the file to see<br>
if it's one of these encodings:<br>
<br>
ucs-bom File must start with a Byte Order Mark (BOM). This<br>
allows detection of 16-bit, 32-bit and utf-8 Unicode<br>
encodings.<br>
utf-8 utf-8 Unicode. This is rejected when a sequence of<br>
bytes is illegal in utf-8.<br>
latin1 The good old 8-bit encoding. Always works.<br>
<br>
When you start editing that 16-bit Unicode file, and it has a BOM, Vim will<br>
detect this and convert the file to utf-8 when reading it. The <a class="Type" href="options.html#'fileencoding'">'fileencoding'</a><br>
option (without s at the end) is set to the detected value. In this case it<br>
is "utf-16le". That means it's Unicode, 16-bit and little-endian. This<br>
file format is common on MS-Windows (e.g., for registry files).<br>
When writing the file, Vim will compare <a class="Type" href="options.html#'fileencoding'">'fileencoding'</a> with <a class="Type" href="options.html#'encoding'">'encoding'</a>. If<br>
they are different, the text will be converted.<br>
An empty value for <a class="Type" href="options.html#'fileencoding'">'fileencoding'</a> means that no conversion is to be done.<br>
Thus the text is assumed to be encoded with <a class="Type" href="options.html#'encoding'">'encoding'</a>.<br>
<br>
If the default <a class="Type" href="options.html#'fileencodings'">'fileencodings'</a> value is not good for you, set it to the<br>
encodings you want Vim to try. Only when a value is found to be invalid will<br>
the next one be used. Putting "latin1" first doesn't work, because it is<br>
never illegal. An example, to fall back to Japanese when the file doesn't<br>
have a BOM and isn't utf-8:<br>
<br>
<div class="helpExample"> :set fileencodings=ucs-bom,utf-8,sjis</div>
<br>
See <a class="Identifier" href="mbyte.html#encoding-values">encoding-values</a> for suggested values. Other values may work as well.<br>
This depends on the conversion available.<br>
<br>
<br>
FORCING AN ENCODING<br>
<br>
If the automatic detection doesn't work you must tell Vim what encoding the<br>
file is. Example:<br>
<br>
<div class="helpExample"> :edit ++enc=koi8-r russian.txt</div>
<br>
The "++enc" part specifies the name of the encoding to be used for this file<br>
only. Vim will convert the file from the specified encoding, Russian in this<br>
example, to <a class="Type" href="options.html#'encoding'">'encoding'</a>. <a class="Type" href="options.html#'fileencoding'">'fileencoding'</a> will also be set to the specified<br>
encoding, so that the reverse conversion can be done when writing the file.<br>
The same argument can be used when writing the file. This way you can<br>
actually use Vim to convert a file. Example:<br>
<br>
<div class="helpExample"> :write ++enc=utf-8 russian.txt</div>
<br>
<span class="Todo">Note</span>:<br>
Conversion may result in lost characters. Conversion from an encoding<br>
to Unicode and back is mostly free of this problem, unless there are<br>
illegal characters. Conversion from Unicode to other encodings often<br>
loses information when there was more than one language in the file.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_45.html#45.5" name="45.5">45.5</a> Entering language text<br>
<br>
Computer keyboards don't have much more than a hundred keys. Some languages<br>
have thousands of characters, Unicode has over hundred thousand. So how do<br>
you type these characters?<br>
First of all, when you don't use too many of the special characters, you<br>
can use digraphs. This was already explained in <a class="Identifier" href="usr_24.html#24.9">24.9</a>.<br>
When you use a language that uses many more characters than keys on your<br>
keyboard, you will want to use an Input Method (IM). This requires learning<br>
the translation from typed keys to resulting character. When you need an IM<br>
you probably already have one on your system. It should work with Vim like<br>
with other programs. For details see <a class="Identifier" href="mbyte.html#mbyte-XIM">mbyte-XIM</a> for the X Window system and<br>
<a class="Identifier" href="mbyte.html#mbyte-IME">mbyte-IME</a> for MS-Windows.<br>
<br>
<br>
KEYMAPS<br>
<br>
For some languages the character set is different from latin, but uses a<br>
similar number of characters. It's possible to map keys to characters. Vim<br>
uses keymaps for this.<br>
Suppose you want to type Hebrew. You can load the keymap like this:<br>
<br>
<div class="helpExample"> :set keymap=hebrew</div>
<br>
Vim will try to find a keymap file for you. This depends on the value of<br>
<a class="Type" href="options.html#'encoding'">'encoding'</a>. If no matching file was found, you will get an error message.<br>
<br>
Now you can type Hebrew in Insert mode. In Normal mode, and when typing a ":"<br>
command, Vim automatically switches to English. You can use this command to<br>
switch between Hebrew and English:<br>
<br>
<div class="helpExample"> CTRL-^</div>
<br>
This only works in Insert mode and Command-line mode. In Normal mode it does<br>
something completely different (jumps to alternate file).<br>
The usage of the keymap is indicated in the mode message, if you have the<br>
<a class="Type" href="options.html#'showmode'">'showmode'</a> option set. In the GUI Vim will indicate the usage of keymaps with<br>
a different cursor color.<br>
You can also change the usage of the keymap with the <a class="Type" href="options.html#'iminsert'">'iminsert'</a> and<br>
<a class="Type" href="options.html#'imsearch'">'imsearch'</a> options.<br>
<br>
To see the list of mappings, use this command:<br>
<br>
<div class="helpExample"> :lmap</div>
<br>
To find out which keymap files are available, in the GUI you can use the<br>
Edit/Keymap menu. Otherwise you can use this command:<br>
<br>
<div class="helpExample"> :echo globpath(&rtp, "keymap/*.vim")</div>
<br>
<br>
DO-IT-YOURSELF KEYMAPS<br>
<br>
You can create your own keymap file. It's not very difficult. Start with<br>
a keymap file that is similar to the language you want to use. Copy it to the<br>
"keymap" directory in your runtime directory. For example, for Unix, you<br>
would use the directory "~/.vim/keymap".<br>
The name of the keymap file must look like this:<br>
<br>
<span class="PreProc">keymap/{name}.vim</span><br>
or<br>
<span class="PreProc">keymap/{name}_{encoding}.vim</span><br>
<br>
<span class="Special">{name}</span> is the name of the keymap. Chose a name that is obvious, but different<br>
from existing keymaps (unless you want to replace an existing keymap file).<br>
<span class="Special">{name}</span> cannot contain an underscore. Optionally, add the encoding used after<br>
an underscore. Examples:<br>
<br>
<span class="PreProc">keymap/hebrew.vim</span><br>
<span class="PreProc">keymap/hebrew_utf-8.vim</span><br>
<br>
The contents of the file should be self-explanatory. Look at a few of the<br>
keymaps that are distributed with Vim. For the details, see <a class="Identifier" href="mbyte.html#mbyte-keymap">mbyte-keymap</a>.<br>
<br>
<br>
LAST RESORT<br>
<br>
If all other methods fail, you can enter any character with <span class="Special">CTRL-V</span>:<br>
<br>
<span class="PreProc">encoding type range</span><br>
8-bit <span class="Special">CTRL-V</span> 123 decimal 0-255<br>
8-bit <span class="Special">CTRL-V</span> x a1 hexadecimal 00-ff<br>
16-bit <span class="Special">CTRL-V</span> u 013b hexadecimal 0000-ffff<br>
31-bit <span class="Special">CTRL-V</span> U 001303a4 hexadecimal 00000000-7fffffff<br>
<br>
Don't type the spaces. See <a class="Identifier" href="insert.html#i_CTRL-V_digit">i_CTRL-V_digit</a> for the details.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<br>
Next chapter: <a class="Identifier" href="usr_90.html">usr_90.txt</a> Installing Vim<br>
<br>
Copyright: see <a class="Identifier" href="usr_01.html#manual-copyright">manual-copyright</a> vim:tw=78:ts=8:ft=help:norl:<br>
</div>
</article>
<footer>
<a href="#top">Return to the top</a> - <a href="index.html">Return to main</a>
<span class="EnglishJapaneseLink">
<span class="CurrentLanguage">English</span>
</span>
<br />
<div style="text-align:right;">
Hosted by <a href="https://github.com/vim-jp/vimdoc-en">vimdoc-en project</a><br />
If you met any problem, please report it to <a href="https://github.com/vim-jp/vimdoc-en/issues">issue</a>.<br />
</div>
</footer>
<!--<script src="js/check-referrer.js" type="text/javascript"></script>-->
</body>
</html>
<!-- vim:set ts=8 sts=2 sw=2 tw=0 et: -->
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。