read_buf_range
Read a specific line range from a Neovim buffer, including unsaved changes. Provide file path and line range; returns lines prefixed with line numbers. Use when you only need a section of a file.
Instructions
Read a specific line range from a Neovim buffer. Read-only; reads from Neovim's in-memory buffer, which may differ from the file on disk if there are unsaved changes.
file: path relative to Neovim's cwd (as shown in get_state buffers).
The buffer must already be open in Neovim; returns an error otherwise.
start_line: first line to read (1-indexed, inclusive).
end_line: last line to read (1-indexed, inclusive). Out-of-range
values are clamped to the buffer bounds. If start_line > end_line
they are swapped automatically.
Use this when you only need a section of a file. Use read_full_buf
instead when you need the entire buffer.
Returns {lines, total_lines}. lines is a list of strings, each prefixed with its 1-based line number (e.g. "10: some code").
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | ||
| start_line | Yes | ||
| end_line | Yes |