"")
local to buffer
File-content encoding for the current buffer. Conversion is done with
iconv() or as specified with 'charconvert'.
When 'fileencoding' is not UTF-8, conversion will be done when
writing the file. For reading see below.
When 'fileencoding' is empty, the file will be saved with UTF-8
encoding (no conversion when reading or writing a file).
WARNING: Conversion to a non-Unicode encoding can cause loss of
information!
See |encoding-names| for the possible values. Additionally, values may be
specified that can be handled by the converter, see
|mbyte-conversion|.
When reading a file 'fileencoding' will be set from 'fileencodings'.
To read a file in a certain encoding it won't work by setting
'fileencoding', use the |++enc| argument. One exception: when
'fileencodings' is empty the value of 'fileencoding' is used.
For a new file the global value of 'fileencoding' is used.
Prepending "8bit-" and "2byte-" has no meaning here, they are ignored.
When the option is set, the value is converted to lowercase. Thus
you can set it with uppercase values too. '_' characters are
replaced with '-'. If a name is recognized from the list at
|encoding-names|, it is replaced by the standard name. For example
"ISO8859-2" becomes "iso-8859-2".
When this option is set, after starting to edit a file, the 'modified'
option is set, because the file would be different when written.
Keep in mind that changing 'fenc' from a modeline happens
AFTER the text has been read, thus it applies to when the file will be
written. If you do set 'fenc' in a modeline, you might want to set
'nomodified' to avoid not being able to ":q".
This option cannot be changed when 'modifiable' is off.
*'fileencodings'* *'fencs'*
'fileencodings' 'fencs' string (default "ucs-bom,utf-8,default,latin1")
global
This is a list of character encodings considered when starting to edit
an existing file. When a file is read, Vim tries to use the first
mentioned character encoding. If an error is detected, the next one
in the list is tried. When an encoding is found that works,
'fileencoding' is set to it. If all fail, 'fileencoding' is set to
an empty string, which means that UTF-8 is used.
WARNING: Conversion can cause loss of information! You can use
the |++bad| argument to specify what is done with characters
that can't be converted.
For an empty file or a file with only ASCII characters most encodings
will work and the first entry of 'fileencodings' will be used (except
"ucs-bom", which requires the BOM to be present). If you prefer
another encoding use an BufReadPost autocommand event to test if your
preferred encoding is to be used. Example: >vim
au BufReadPost * if search('\S', 'w') == 0 |
\ set fenc=iso-2022-jp | endif
< This sets 'fileencoding' to "iso-2022-jp" if the file does not contain
non-blank characters.
When the |++enc| argument is used then the value of 'fileencodings' is
not used.
Note that 'fileencodings' is not used for a new file, the global value
of 'fileencoding' is used instead. You can set it with: >vim
setglobal fenc=iso-8859-2
< This means that a non-existing file may get a different encoding than
an empty file.
The special value "ucs-bom" can be used to check for a Unicode BOM
(Byte Order Mark) at the start of the file. It must not be preceded
by "utf-8" or another Unicode encoding for this to work properly.
An entry for an 8-bit encoding (e.g., "latin1") should be the last,
because Vim cannot detect an error, thus the encoding is always
accepted.
The special value "default" can be used for the encoding from the
environment. It is useful when your environment uses a non-latin1
encoding, such as Russian.
When a file contains an illegal UTF-8 byte sequence it won't be
recognized as "utf-8". You can use the |8g8| command to find the
illegal byte sequence.
WRONG VALUES: WHAT'S WRONG:
latin1,utf-8 "latin1" will always be used
utf-8,ucs-bom,latin1