Home Explore Blog CI



neovim

32th chunk of `runtime/doc/api.txt`
6a02bfbf86ea8a10371d69ff7e9364fd9ef5bbc4c42cfb150000000100000fd2
 Attributes: ~
        Since: 0.6.0

    Parameters: ~
      • {buffer}  Buffer to set the mark on
      • {name}    Mark name

    Return: ~
        true if the mark was deleted, else false.

    See also: ~
      • |nvim_buf_set_mark()|
      • |nvim_del_mark()|

nvim_buf_del_var({buffer}, {name})                        *nvim_buf_del_var()*
    Removes a buffer-scoped (b:) variable

    Attributes: ~
        Since: 0.1.0

    Parameters: ~
      • {buffer}  Buffer id, or 0 for current buffer
      • {name}    Variable name

nvim_buf_delete({buffer}, {opts})                          *nvim_buf_delete()*
    Deletes a buffer and its metadata (like |:bwipeout|).

    To get |:bdelete| behavior, reset 'buflisted' and pass `unload=true`: >lua
        vim.bo.buflisted = false
        vim.api.nvim_buf_delete(0, { unload = true })
<

    Attributes: ~
        not allowed when |textlock| is active or in the |cmdwin|
        Since: 0.5.0

    Parameters: ~
      • {buffer}  Buffer id, or 0 for current buffer
      • {opts}    Optional parameters. Keys:
                  • force: Force deletion, ignore unsaved changes.
                  • unload: Unloaded only (|:bunload|), do not delete.

nvim_buf_detach({buffer})                                  *nvim_buf_detach()*
    Deactivates buffer-update events on the channel.

    Attributes: ~
        |RPC| only
        Since: 0.3.0

    Parameters: ~
      • {buffer}  Buffer id, or 0 for current buffer

    Return: ~
        False if detach failed (because the buffer isn't loaded); otherwise
        True.

    See also: ~
      • |nvim_buf_attach()|
      • |api-lua-detach| for detaching Lua callbacks

nvim_buf_get_changedtick({buffer})                *nvim_buf_get_changedtick()*
    Gets a changed tick of a buffer

    Attributes: ~
        Since: 0.2.0

    Parameters: ~
      • {buffer}  Buffer id, or 0 for current buffer

    Return: ~
        `b:changedtick` value.

nvim_buf_get_keymap({buffer}, {mode})                  *nvim_buf_get_keymap()*
    Gets a list of buffer-local |mapping| definitions.

    Attributes: ~
        Since: 0.2.1

    Parameters: ~
      • {buffer}  Buffer id, or 0 for current buffer
      • {mode}    Mode short-name ("n", "i", "v", ...)

    Return: ~
        Array of |maparg()|-like dictionaries describing mappings. The
        "buffer" key holds the associated buffer id.

                                                        *nvim_buf_get_lines()*
nvim_buf_get_lines({buffer}, {start}, {end}, {strict_indexing})
    Gets a line-range from the buffer.

    Indexing is zero-based, end-exclusive. Negative indices are interpreted as
    length+1+index: -1 refers to the index past the end. So to get the last
    element use start=-2 and end=-1.

    Out-of-bounds indices are clamped to the nearest valid value, unless
    `strict_indexing` is set.

    Attributes: ~
        Since: 0.1.0

    Parameters: ~
      • {buffer}           Buffer id, or 0 for current buffer
      • {start}            First line index
      • {end}              Last line index, exclusive
      • {strict_indexing}  Whether out-of-bounds should be an error.

    Return: ~
        Array of lines, or empty array for unloaded buffer.

    See also: ~
      • |nvim_buf_get_text()|

nvim_buf_get_mark({buffer}, {name})                      *nvim_buf_get_mark()*
    Returns a `(row,col)` tuple representing the position of the named mark.
    "End of line" column position is returned as |v:maxcol| (big number). See
    |mark-motions|.

    Marks are (1,0)-indexed. |api-indexing|

    Attributes: ~
        Since: 0.1.0

    Parameters: ~
      • {buffer}  Buffer id, or 0 for current buffer
      • {name}    Mark name

    Return: ~
        (row, col) tuple, (0, 0) if the mark is not set, or is an
        uppercase/file mark set in another buffer.

    See also: ~
      • |nvim_buf_set_mark()|
      • |nvim_buf_del_mark()|

nvim_buf_get_name({buffer})                              *nvim_buf_get_name()*
 

Title: nvim_buf_delete, nvim_buf_detach, nvim_buf_get_changedtick, nvim_buf_get_keymap, nvim_buf_get_lines, nvim_buf_get_mark: Buffer API Functions
Summary
This section details more Neovim buffer API functions. `nvim_buf_delete` deletes a buffer and its metadata. `nvim_buf_detach` deactivates buffer-update events. `nvim_buf_get_changedtick` gets the changed tick of a buffer. `nvim_buf_get_keymap` retrieves buffer-local keymap definitions. `nvim_buf_get_lines` retrieves a range of lines from the buffer, and `nvim_buf_get_mark` returns the position of a named mark in the buffer.