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

x/ddc_vim/deps.ts>fn.setline

Dark deno-powered completion framework for neovim/Vim
Go to Latest
function fn.setline
import { fn } from "https://deno.land/x/ddc_vim@v4.0.5/deps.ts";
const { setline } = fn;

Set line {lnum} of the current buffer to {text}. To insert lines use append(). To set lines in another buffer use setbufline(). Any text properties in {lnum} are cleared.

{lnum} is used like with getline(). When {lnum} is just below the last line the {text} will be added below the last line. {text} can be any type or a List of any type, each item is converted to a String. When {text} is an empty List then nothing is changed and FALSE is returned.

If this succeeds, FALSE is returned. If this fails (most likely because {lnum} is invalid) TRUE is returned. In Vim9 script an error is given if {lnum} is invalid.

Example:

:call setline(5, strftime("%c"))

When {text} is a List then line {lnum} and following lines will be set to the items in the list. Example:

:call setline(5, ['aaa', 'bbb', 'ccc'])

This is equivalent to:

:for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
:  call setline(n, l)
:endfor

Note: The '[ and '] marks are not set.

Can also be used as a method, the base is passed as the second argument:

GetText()->setline(lnum)

Parameters

denops: Denops
lnum: string | number
text: string | string[]

Returns

Promise<boolean>