Skip to main content
Module

x/ddc_vim/deps.ts>fn.writefile

Dark deno-powered completion framework for neovim/Vim8
Go to Latest
function fn.writefile
import { fn } from "https://deno.land/x/ddc_vim@v2.3.0/deps.ts";
const { writefile } = fn;

When {object} is a |List| write it to file {fname}. Each list item is separated with a NL. Each list item must be a String or Number. When {flags} contains "b" then binary mode is used: There will not be a NL after the last list item. An empty item at the end does cause the last line in the file to end in a NL. When {object} is a |Blob| write the bytes to file {fname} unmodified. When {flags} contains "a" then append mode is used, lines are appended to the file: :call writefile(["foo"], "event.log", "a") :call writefile(["bar"], "event.log", "a") When {flags} contains "s" then fsync() is called after writing the file. This flushes the file to disk, if possible. This takes more time but avoids losing the file if the system crashes. When {flags} does not contain "S" or "s" then fsync() is called if the 'fsync' option is set. When {flags} contains "S" then fsync() is not called, even when 'fsync' is set. All NL characters are replaced with a NUL character. Inserting CR characters needs to be done before passing {list} to writefile(). An existing file is overwritten, if possible. When the write fails -1 is returned, otherwise 0. There is an error message if the file can't be created or when writing fails. Also see |readfile()|. To copy a file byte for byte: :let fl = readfile("foo", "b") :call writefile(fl, "foocopy", "b") Can also be used as a |method|: GetText()->writefile("thefile")

Parameters

denops: Denops
object: unknown
fname: unknown
optional
flags: unknown

Returns

Promise<unknown>