Home Explore Blog CI



neovim

35th chunk of `runtime/doc/api.txt`
ffabb5bd98db16d545bd712007150408cc6d3dcb488247100000000100000fe1
 |mark-motions|.

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

    Note: ~
      • Passing 0 as line deletes the mark

    Attributes: ~
        Since: 0.6.0

    Parameters: ~
      • {buffer}  Buffer to set the mark on
      • {name}    Mark name
      • {line}    Line number
      • {col}     Column/row number
      • {opts}    Optional parameters. Reserved for future use.

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

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

nvim_buf_set_name({buffer}, {name})                      *nvim_buf_set_name()*
    Sets the full file name for a buffer, like |:file_f|

    Attributes: ~
        Since: 0.1.0

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

                                                         *nvim_buf_set_text()*
nvim_buf_set_text({buffer}, {start_row}, {start_col}, {end_row}, {end_col},
                  {replacement})
    Sets (replaces) a range in the buffer

    This is recommended over |nvim_buf_set_lines()| when only modifying parts
    of a line, as extmarks will be preserved on non-modified parts of the
    touched lines.

    Indexing is zero-based. Row indices are end-inclusive, and column indices
    are end-exclusive.

    To insert text at a given `(row, column)` location, use
    `start_row = end_row = row` and `start_col = end_col = col`. To delete the
    text in a range, use `replacement = {}`.

    Note: ~
      • Prefer |nvim_buf_set_lines()| (for performance) to add or delete
        entire lines.
      • Prefer |nvim_paste()| or |nvim_put()| to insert (instead of replace)
        text at cursor.

    Attributes: ~
        not allowed when |textlock| is active
        Since: 0.5.0

    Parameters: ~
      • {buffer}       Buffer id, or 0 for current buffer
      • {start_row}    First line index
      • {start_col}    Starting column (byte offset) on first line
      • {end_row}      Last line index, inclusive
      • {end_col}      Ending column (byte offset) on last line, exclusive
      • {replacement}  Array of lines to use as replacement

nvim_buf_set_var({buffer}, {name}, {value})               *nvim_buf_set_var()*
    Sets a buffer-scoped (b:) variable

    Attributes: ~
        Since: 0.1.0

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


==============================================================================
Extmark Functions                                                *api-extmark*

                                                  *nvim_buf_clear_namespace()*
nvim_buf_clear_namespace({buffer}, {ns_id}, {line_start}, {line_end})
    Clears |namespace|d objects (highlights, |extmarks|, virtual text) from a
    region.

    Lines are 0-indexed. |api-indexing| To clear the namespace in the entire
    buffer, specify line_start=0 and line_end=-1.

    Attributes: ~
        Since: 0.3.2

    Parameters: ~
      • {buffer}      Buffer id, or 0 for current buffer
      • {ns_id}       Namespace to clear, or -1 to clear all namespaces.
      • {line_start}  Start of range of lines to clear
      • {line_end}    End of range of lines to clear (exclusive) or -1 to
                      clear to end of buffer.

nvim_buf_del_extmark({buffer}, {ns_id}, {id})         *nvim_buf_del_extmark()*
    Removes an |extmark|.

    Attributes: ~
        Since: 0.5.0

    Parameters: ~
      • {buffer}  Buffer id, or 0 for current buffer
      • {ns_id}   Namespace id from |nvim_create_namespace()|
      • {id}      Extmark id

    Return: ~
        true if the extmark was found, else false

                                                *nvim_buf_get_extmark_by_id()*
nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {opts})
    Gets the position (0-indexed) of an |extmark|.

    Attributes: ~
        Since: 0.5.0

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

Title: nvim_buf_set_text, nvim_buf_set_var, nvim_buf_clear_namespace, nvim_buf_del_extmark, nvim_buf_get_extmark_by_id: More Buffer and Extmark Functions
Summary
This section details more Neovim buffer and extmark API functions. `nvim_buf_set_text` sets a range of text in the buffer, recommended over `nvim_buf_set_lines` for partial line modifications to preserve extmarks. `nvim_buf_set_var` sets a buffer-scoped variable. `nvim_buf_clear_namespace` clears namespaced objects from a region of the buffer. `nvim_buf_del_extmark` removes an extmark. `nvim_buf_get_extmark_by_id` gets the position of an extmark.