Home Explore Blog CI



neovim

38th chunk of `runtime/doc/options.txt`
7630937e9d49b99d883b0e203c1df413c5d551099d6eba120000000100000fa1
 '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	BOM won't be recognized in an utf-8
					file
		cp1250,latin1		"cp1250" will always be used
	If 'fileencodings' is empty, 'fileencoding' is not modified.
	See 'fileencoding' for the possible values.
	Setting this option does not have an effect until the next time a file
	is read.

						*'fileformat'* *'ff'*
'fileformat' 'ff'	string	(default Windows: "dos", Unix: "unix")
			local to buffer
	This gives the <EOL> of the current buffer, which is used for
	reading/writing the buffer from/to a file:
	    dos	    <CR><NL>
	    unix    <NL>
	    mac	    <CR>
	When "dos" is used, CTRL-Z at the end of a file is ignored.
	See |file-formats| and |file-read|.
	For the character encoding of the file see 'fileencoding'.
	When 'binary' is set, the value of 'fileformat' is ignored, file I/O
	works like it was set to "unix".
	This option is set automatically when starting to edit a file and
	'fileformats' is not empty and 'binary' is off.
	When this option is set, after starting to edit a file, the 'modified'
	option is set, because the file would be different when written.
	This option cannot be changed when 'modifiable' is off.

						*'fileformats'* *'ffs'*
'fileformats' 'ffs'	string	(default Windows: "dos,unix", Unix: "unix,dos")
			global
	This gives the end-of-line (<EOL>) formats that will be tried when
	starting to edit a new buffer and when reading a file into an existing
	buffer:
	- When empty, the format defined with 'fileformat' will be used
	  always.  It is not set automatically.
	- When set to one name, that format will be used whenever a new buffer
	  is opened.  'fileformat' is set accordingly for that buffer.  The
	  'fileformats' name will be used when a file is read into an existing
	  buffer, no matter what 'fileformat' for that buffer is set to.
	- When more than one name is present, separated by commas, automatic
	  <EOL> detection will be done when reading a file.  When starting to
	  edit a file, a check is done for the <EOL>:
	  1. If all lines end in <CR><NL>, and 'fileformats' includes "dos",
	     'fileformat' is set to "dos".
	  2. If a <NL> is found and 'fileformats' includes "unix", 'fileformat'
	     is set to "unix".  Note that when a <NL> is found without a
	     preceding <CR>, "unix" is preferred over "dos".
	  3. If 'fileformat' has not yet been set, and if a <CR> is found, and
	     if 'fileformats' includes "mac", 'fileformat' is set to "mac".
	     This means that "mac" is only chosen when:
	      "unix" is not present or no <NL> is found in the file, and
	      "dos" is not present or no <CR><NL> is found in the file.
	     Except: if "unix" was chosen, but there is a <CR> before
	     the first <NL>, and there appear to be more <CR>s than <NL>s in
	     the first few lines, "mac" is used.
	  4. If 'fileformat' is still not set, the first name from
	     'fileformats' is used.
	  When reading a file into an existing buffer, the same is done, but
	  this happens like 'fileformat' has been set appropriately for that

Title: Vim Options: 'fileencodings' (continued), 'fileformat' and 'fileformats'
Summary
This section continues describing the 'fileencodings' option, listing examples of incorrect values and the reasons why. It then introduces the 'fileformat' option, which determines the end-of-line (EOL) character(s) used in a buffer (dos, unix, or mac). Finally, it explains the 'fileformats' option, which specifies the order in which Vim attempts to detect the EOL format when opening a file. It details the rules Vim uses to automatically set 'fileformat' based on the contents of the file and the order of formats in 'fileformats'.