Replace a line range
nvim_edit_linesReplace file lines with new text by line range and receive updated LSP diagnostics. Saves the buffer without format-on-save to keep the diff minimal.
Instructions
This is the default way to edit files. Use the provided line numbers to directly replace lines start_line..end_line (1-based, inclusive) with new text. Saves the buffer by default without running format-on-save autocmds, so the diff is minimal. Returns fresh LSP diagnostics for the file.Use nvim_format to format after editing once editing and fixes on that are done.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File path | |
| save | No | Write the buffer, default true | |
| text | Yes | Replacement text; use \n for several lines | |
| end_line | Yes | Last line to replace, inclusive | |
| start_line | Yes | First line to replace, 1-based |