Google

星期日, 八月 26, 2007

vi使用utf-8编码

用VIM,有个文件需要用UTF-8编码,查到点有用的东西。:)Help文件里的,如果Help文件支持查询就好了。;)
http://www.vim.org/htmldoc/mbyte.html

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

If your locale works properly, Vim will try to set the 'encoding' option
accordingly. If this doesn't work you can overrule its value:

:set encoding=utf-8

See |encoding-values| for a list of acceptable values.

The result is that all the text that is used inside Vim will be in this
encoding. Not only the text in the buffers, but also in registers, variables,
etc. This also means that changing the value of 'encoding' makes the existing
text invalid! The text doesn't change, but it will be displayed wrong.

You can edit files in another encoding than what 'encoding' is set to. Vim
will convert the file when you read it and convert it back when you write it.
See 'fileencoding', 'fileencodings' and |++enc|.

0 条评论:

发表评论

<< 主页

辽ICP备05003652号
流风洄雪听天籁,轻云蔽日看落花

Powered by Blogger