Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ddc_vim/deps.ts>op.fileformats

Dark deno-powered completion framework for neovim/Vim
Go to Latest
variable op.fileformats
import { op } from "https://deno.land/x/ddc_vim@v4.3.0/deps.ts";
const { fileformats } = op;

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 file only, the option is not changed. When 'binary' is set, the value of 'fileformats' is not used.

When Vim starts up with an empty buffer the first item is used. You can overrule this by setting 'fileformat' in your .vimrc.

For systems with a Dos-like <EOL> (<CR><NL>), when reading files that are ":source"ed and for vimrc files, automatic <EOL> detection may be done:

  • When 'fileformats' is empty, there is no automatic detection. Dos format will be used.
  • When 'fileformats' is set to one or more names, automatic detection is done. This is based on the first <NL> in the file: If there is a <CR> in front of it, Dos format is used, otherwise Unix format is used. Also see file-formats. For backwards compatibility: When this option is set to an empty string or one format (no comma is included), 'textauto' is reset, otherwise 'textauto' is set. NOTE: This option is set to the Vi default value when 'compatible' is set and to the Vim default value when 'compatible' is reset.

(default: Vim+Vi MS-Windows: "dos,unix", Vim Unix, macOS: "unix,dos", Vi Cygwin: "unix,dos", Vi others: "")

type

GlobalOption<string>