Buffer Class

class pynvim.api.Buffer(session, code_data)[source]

A remote Nvim buffer.

add_highlight(hl_group, line, col_start=0, col_end=-1, src_id=-1, async_=None, **kwargs)[source]

Add a highlight to the buffer.

append(lines, index=-1)[source]

Append a string or list of lines to the buffer.

clear_highlight(src_id, line_start=0, line_end=-1, async_=None, **kwargs)[source]

Clear highlights from the buffer.

mark(name)[source]

Return (row, col) tuple for a named mark.

name

Get the buffer name.

number

Get the buffer number.

range(start, end)[source]

Return a Range object, which represents part of the Buffer.

update_highlights(src_id, hls, clear_start=0, clear_end=-1, clear=False, async_=True)[source]

Add or update highlights in batch to avoid unnecessary redraws.

A src_id must have been allocated prior to use of this function. Use for instance nvim.new_highlight_source() to get a src_id for your plugin.

hls should be a list of highlight items. Each item should be a list or tuple on the form (“GroupName”, linenr, col_start, col_end) or (“GroupName”, linenr) to highlight an entire line.

By default existing highlights are preserved. Specify a line range with clear_start and clear_end to replace highlights in this range. As a shorthand, use clear=True to clear the entire buffer before adding the new highlights.

valid

Return True if the buffer still exists.