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

x/ddc_vim/deps.ts>fn.bufnr

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

The result is the number of a buffer, as it is displayed by the :ls command. For the use of {buf}, see bufname() above.

If the buffer doesn't exist, -1 is returned. Or, if the {create} argument is present and TRUE, a new, unlisted, buffer is created and its number is returned. Example:

let newbuf = bufnr('Scratch001', 1)

Using an empty name uses the current buffer. To create a new buffer with an empty name use bufadd().

bufnr("$") is the last buffer:

:let last_buffer = bufnr("$")

The result is a Number, which is the highest buffer number of existing buffers. Note that not all buffers with a smaller number necessarily exist, because ":bwipeout" may have removed them. Use bufexists() to test for the existence of a buffer.

Can also be used as a method:

echo bufref->bufnr()

Obsolete name: buffer_number().

Obsolete name for bufnr("$"): last_buffer_nr().

Parameters

denops: Denops
optional
buf: BufNameArg
optional
create: boolean

Returns

Promise<number>