import { bufnr } from "https://deno.land/x/denops_std@v5.0.2/function/mod.ts";
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().