Skip to main content
Module

x/denops_std/function/mod.ts>insert

📚 Standard module for denops.vim
Go to Latest
function insert
import { insert } from "https://deno.land/x/denops_std@v6.4.0/function/mod.ts";

When {object} is a List or a Blob insert {item} at the start of it.

If {idx} is specified insert {item} before the item with index {idx}. If {idx} is zero it goes before the first item, just like omitting {idx}. A negative {idx} is also possible, see list-index. -1 inserts just before the last item.

Returns the resulting List or Blob. Examples:

:let mylist = insert([2, 3, 5], 1)
:call insert(mylist, 4, -1)
:call insert(mylist, 6, len(mylist))

The last example can be done simpler with add(). Note that when {item} is a List it is inserted as a single item. Use extend() to concatenate Lists.

Can also be used as a method:

mylist->insert(item)

Parameters

denops: Denops
object: unknown
item: unknown
optional
idx: unknown

Returns

Promise<unknown[]>