Skip to main content
Module

x/denops_std/function/buffer.ts

📚 Standard module for denops.vim
Go to Latest
import * as denopsStd from "https://deno.land/x/denops_std@v3.12.1/function/buffer.ts";

Functions

Add a buffer to the buffer list with {name}. If a buffer for file {name} already exists, return that buffer number. Otherwise return the buffer number of the newly created buffer. When {name} is an empty string then a new buffer is always created. The buffer will not have' 'buflisted' set.

The result is a Number, which is |TRUE| if a buffer called {expr} exists. If the {expr} argument is a number, buffer numbers are used. Number zero is the alternate buffer for the current window.

The result is a Number, which is |TRUE| if a buffer called {expr} exists and is listed (has the 'buflisted' option set). The {expr} argument is used like with |bufexists()|.

Ensure the buffer {expr} is loaded. When the buffer name refers to an existing file then the file is read. Otherwise the buffer will be empty. If the buffer was already loaded then there is no change. If there is an existing swap file for the file of the buffer, there will be no dialog, the buffer will be loaded anyway. The {expr} argument is used like with |bufexists()|.

The result is a Number, which is |TRUE| if a buffer called {expr} exists and is loaded (shown in a window or hidden). The {expr} argument is used like with |bufexists()|.

The result is the name of a buffer, as it is displayed by the ":ls" command. If {expr} is omitted the current buffer is used. If {expr} is a Number, that buffer number's name is given. Number zero is the alternate buffer for the current window. If {expr} is a String, it is used as a |file-pattern| to match with the buffer names. This is always done like 'magic' is set and 'cpoptions' is empty. When there is more than one match an empty string is returned. "" or "%" can be used for the current buffer, "#" for the alternate buffer. A full match is preferred, otherwise a match at the start, end or middle of the buffer name is accepted. If you only want a full match then put "^" at the start and "$" at the end of the pattern. Listed buffers are found first. If there is a single match with a listed buffer, that one is returned. Next unlisted buffers are searched for. If the {expr} is a String, but you want to use it as a buffer number, force it to be a Number by adding zero to it: > :echo bufname("3" + 0) If the buffer doesn't exist, or doesn't have a name, an empty string is returned. bufname("#") alternate buffer name bufname(3) name of buffer 3 bufname("%") name of current buffer bufname("file2") name of buffer where "file2" matches.

The result is the number of a buffer, as it is displayed by the ":ls" command. For the use of {expr}, see |bufname()| above. If the buffer doesn't exist, -1 is returned. Or, if the {create} argument is present and not zero, a new, unlisted, buffer is created and its number is returned. 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.

The result is a Number, which is the |window-ID| of the first window associated with buffer {expr}. For the use of {expr}, see |bufname()| above. If buffer {expr} doesn't exist or there is no such window, -1 is returned. Example: >

The result is a Number, which is the number of the first window associated with buffer {expr}. For the use of {expr}, see |bufname()| above. If buffer {expr} doesn't exist or there is no such window, -1 is returned. Example: >

Return a |List| with the lines starting from {lnum} to {end} (inclusive) in the buffer {expr}. If {end} is omitted, a |List| with only the line {lnum} is returned.

Set line {lnum} to {text} in buffer {expr}. To insert lines use |append()|.