How to change encoding on vi editor?

You can get all below information on vi editor
on command prompt: help encoding

                                        *'encoding'* *'enc'* *E543*
'encoding' 'enc'        string (default: "latin1" or value from $LANG)
                        {only available when compiled with the |+multi_byte|
                        {not in Vi}
        Sets the character encoding used inside Vim.  It applies to text in
        the buffers, registers, Strings in expressions, text stored in the
        viminfo file, etc.  It sets the kind of characters which Vim can work
        with.  See |encoding-names| for the possible values.

        NOTE: Changing this option will not change the encoding of the
        existing text in Vim.  It may cause multi-byte text to become invalid.
        It should normally be kept at its default value, or set when Vim
        starts up.  See |multibyte|.

        NOTE: For GTK+ 2 it is highly recommended to set 'encoding' to
        "utf-8".  Although care has been taken to allow different values of
        'encoding', "utf-8" is the natural choice for the environment and
        avoids unnecessary conversion overhead.  "utf-8" has not been made
        the default to prevent different behaviour of the GUI and terminal
        versions, and to avoid changing the encoding of newly created files
        without your knowledge (in case 'fileencodings' is empty).

        The character encoding of files can be different from 'encoding'.
        This is specified with 'fileencoding'.  The conversion is done with
        iconv() or as specified with 'charconvert'.

        Normally 'encoding' will be equal to your current locale.  This will
        be the default if Vim recognizes your environment settings.  If
        'encoding' is not set to the current locale, 'termencoding' must be
        set to convert typed and displayed text.  See |encoding-table|.

        When you set this option, it fires the |EncodingChanged| autocommand
        event so that you can set up fonts if necessary.

        When the option is set, the value is converted to lowercase.  Thus
        you can set it with uppercase values too.  Underscores are translated
        to '-' signs.
        When the encoding is recognized, it is changed to the standard name.
        For example "Latin-1" becomes "latin1", "ISO_88592" becomes
        "iso-8859-2" and "utf8" becomes "utf-8".

        Note: "latin1" is also used when the encoding could not be detected.
        This only works when editing files in the same encoding!  When the
        actual characterset is not latin1, make sure 'fileencoding' and
        'fileencodings' are empty.  When conversion is needed, switch to using

        When "unicode", "ucs-2" or "ucs-4" is used, Vim internally uses utf-8.
        You don't notice this while editing, but it does matter for the
        |viminfo-file|.  And Vim expects the terminal to use utf-8 too.  Thus
        setting 'encoding' to one of these values instead of utf-8 only has
        effect for encoding used for files when 'fileencoding' is empty.

         When 'encoding' is set to a Unicode encoding, and 'fileencodings' was
         not set yet, the default for 'fileencodings' is changed.

Vim can use many 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.

Other encodings cannot be used by Vim internally.  But files in other
encodings can be edited by using conversion, see 'fileencoding'.
Note that all encodings must use ASCII for the characters up to 128 (except
when compiled for EBCDIC).

Supported 'encoding' values are:                        *encoding-values*
1   latin1      8-bit characters (ISO 8859-1)
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   cp{number}  MS-Windows: any installed single-byte codepage
2   cp932       Japanese (Windows only)
2   euc-jp      Japanese (Unix only)
2   sjis        Japanese (Unix only)
2   cp949       Korean (Unix and Windows)
2   euc-kr      Korean (Unix only)
2   cp936       simplified Chinese (Windows only)
2   euc-cn      simplified Chinese (Unix only)
2   cp950       traditional Chinese (on Unix alias for big5)
2   big5        traditional Chinese (on Windows alias for cp950)
2   euc-tw      traditional Chinese (Unix only)
2   2byte-{name} Unix: 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 the encoding of the file and the current locale.
For MS-Windows "cp{number}" means using codepage {number}.
Examples: >
                :set encoding=8bit-cp1252
                :set encoding=2byte-cp932
Several aliases can be used, they are translated to one of the names above.
An incomplete list:

1   ansi        same as latin1 (obsolete, for backward compatibility)
2   japan       Japanese: on Unix "euc-jp", on MS-Windows cp932
2   korea       Korean: on Unix "euc-kr", on MS-Windows cp949
2   prc         simplified Chinese: on Unix "euc-cn", on MS-Windows cp936
2   chinese     same as "prc"
2   taiwan      traditional Chinese: on Unix "euc-tw", on MS-Windows cp950
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)

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

Normally 'encoding' is equal to your current locale and 'termencoding' is
empty.  This means that your keyboard and display work with characters encoded
in your current locale, and Vim uses the same characters internally.

You can make Vim use characters in a different encoding by setting the
'encoding' option to a different value.  Since the keyboard and display still
use the current locale, conversion needs to be done.  The 'termencoding' then
takes over the value of the current locale, so Vim converts between 'encoding'
and 'termencoding'.  Example: >
        :let &termencoding = &encoding
        :set encoding=utf-8

However, not all combinations of values are possible.  The table below tells
you how each of the nine combinations works.  This is further restricted by
not all conversions being possible, iconv() being present, etc.  Since this
depends on the system used, no detailed list can be given.
('tenc' is the short name for 'termencoding' and 'enc' short for 'encoding')

'tenc'      'enc'       remark ~

 8bit       8bit        Works.  When 'termencoding' is different from
                        'encoding' typing and displaying may be wrong for some
                        characters, Vim does NOT perform conversion (set
                        'encoding' to "utf-8" to get this).
 8bit      2byte        MS-Windows: works for all codepages installed on your
                        system; you can only type 8bit characters;
                        Other systems: does NOT work.
 8bit      Unicode      Works, but you can only type 8bit characters; in a
                        terminal you can only see 8bit characters; the GUI can
                        show all characters that the 'guifont' supports.

 2byte      8bit        Works, but typing non-ASCII characters might
                        be a problem.
 2byte     2byte        MS-Windows: works for all codepages installed on your
                        system; typing characters might be a problem when
                        locale is different from 'encoding'.
                        Other systems: Only works when 'termencoding' is equal
                        to 'encoding', you might as well leave it empty.
 2byte     Unicode      works, Vim will translate typed characters.

 Unicode    8bit        works (unusual)
 Unicode    2byte       does NOT work
 Unicode   Unicode      works very well (leaving 'termencoding' empty works
                        the same way, because all Unicode is handled
                        internally as UTF-8)

CONVERSION                                              *charset-conversion*

Vim will automatically convert from one to another encoding in several places:
- When reading a file and 'fileencoding' is different from 'encoding'
- When writing a file and 'fileencoding' is different from 'encoding'
- When displaying characters and 'termencoding' is different from 'encoding'
- When reading input and 'termencoding' is different from 'encoding'
- When displaying messages and the encoding used for LC_MESSAGES differs from
  'encoding' (requires a gettext version that supports this).
- When reading a Vim script where |:scriptencoding| is different from
- When reading or writing a |viminfo| file.
Most of these require the |+iconv| feature.  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

    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:

    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:

    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:

    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:

by 아비숑 | 2007/09/21 10:52 | IT Life | 트랙백(2) | 덧글(0)

트랙백 주소 :
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]
Tracked from コーチ 新作 at 2014/07/28 17:31

제목 : Billige Toms Sko
の Top コーチ 新作 datum 100パーセントゼロコストの命令ディレクトリ コーチ 激安 それはスタイルが個人所有の移動してください:あなたはしたい場合がありますが、説明責任 /> コーチ 新作。 獲得し、私は​​たとえば、あなたを与えるを見て「彼らは非常 オークリー に 十分 、考えてみてください。 ""これらのセクションのセクションでは、最終決定を所有したことがない - 私は あなたは間違いなく非常に可能性、これらにピックアップします理由を理解しているhuan​​hang......more

Tracked from クリスチャンルブタン 銀.. at 2014/07/29 15:34

제목 : アシックス スパイク
  吃柿子应该以一餐一个为 クリスチャンルブタン 銀座 宜,因为柿子虽然有很好的营养及医疗作用,但是它有涩味,吃多了会感到口涩舌麻,收敛作用很强,引起大便干燥。   芒果有益胃、止呕、止晕 ジミーチュウ バッグ 的功效,对于眩晕症、梅尼埃综合征、高血压晕眩、恶心呕吐等均有疗效。果肉或以芒果煎水进食对孕妇作呕也有很好的效果。对芒果过敏的孕妈则不可食用。 スタイル="font-size:14px " >;、   柑橘品种繁多,有甜橙、南橘、无核蜜橘、柚子等。它们都......more

:         :


비공개 덧글

◀ 이전 페이지          다음 페이지 ▶

'="text/javascript" src="">');