Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
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@v6.3.0/function/buffer.ts";

Functions

Like append() but append the text in buffer {buf}.

Add a buffer to the buffer list with name {name} (must be a String). 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 and not be loaded yet. To add some text to the buffer use this:

The result is a Number, which is TRUE if a buffer called {buf} exists. If the {buf} 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 {buf} exists and is listed (has the 'buflisted' option set). The {buf} argument is used like with bufexists().

Ensure the buffer {buf} 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 the buffer is not related to a file then no file is read (e.g., when 'buftype' is "nofile"). 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 {buf} argument is used like with bufexists().

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

The result is the name of a buffer. Mostly as it is displayed by the :ls command, but not using special names such as "[No Name]". If {buf} is omitted the current buffer is used. If {buf} is a Number, that buffer number's name is given. Number zero is the alternate buffer for the current window. If {buf} 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 {buf} is a String, but you want to use it as a buffer number, force it to be a Number by adding zero to it:

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

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

Like bufwinid() but return the window number instead of the window-ID. If buffer {buf} doesn't exist or there is no such window, -1 is returned. Example:

Delete lines {first} to {last} (inclusive) from buffer {buf}. If {last} is omitted then delete line {first} only. On success 0 is returned, on failure 1 is returned.

Get information about buffers as a List of Dictionaries.

Return a List with the lines starting from {lnum} to {end} (inclusive) in the buffer {buf}. If {end} is omitted, a List with only the line {lnum} is returned. See getbufoneline() for only getting the line.

The result is the value of option or local buffer variable {varname} in buffer {buf}. Note that the name without "b:" must be used. The {varname} argument is a string. When {varname} is empty returns a Dictionary with all the buffer-local variables. When {varname} is equal to "&" returns a Dictionary with all the buffer-local options. Otherwise, when {varname} starts with "&" returns the value of a buffer-local option. This also works for a global or buffer-local option, but it doesn't work for a global variable, window-local variable or window-local option. For the use of {buf}, see bufname() above. When the buffer or variable doesn't exist {def} or an empty string is returned, there is no error message. Examples:

Returns the changelist for the buffer {buf}. For the use of {buf}, see bufname() above. If buffer {buf} doesn't exist, an empty list is returned.

Without the {buf} argument returns a List with information about all the global marks. mark

Set line {lnum} to {text} in buffer {buf}. This works like setline() for the specified buffer.

Set option or local variable {varname} in buffer {buf} to {val}. This also works for a global or local window option, but it doesn't work for a global or local window variable. For a local window option the global value is unchanged. For the use of {buf}, see bufname() above. The {varname} argument is a string. Note that the variable name without "b:" must be used. Examples:

The result is the swap file path of the buffer {expr}. For the use of {buf}, see bufname() above. If buffer {buf} is the current buffer, the result is equal to :swapname (unless there is no swap file). If buffer {buf} has no swap file, returns an empty string.

Interfaces

Only the buffers matching the specified criteria are returned.

Type Aliases

If the {buf} argument is a number, buffer numbers are used. Number zero is the alternate buffer for the current window.

For {lnum} and {end} "$" can be used for the last line of the buffer. Otherwise a number must be used.

If {buf} is omitted the current buffer is used. If {buf} is a Number, that buffer number's name is given. Number zero is the alternate buffer for the current window. If {buf} 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.