replace_lines_in_file
Modify specific lines in a file by replacing content between defined start and end line numbers. Verify changes using expected line content for accurate file manipulation.
Instructions
Replace content between specific line numbers in a file.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
contents | Yes | New content to replace the lines with | |
file_path | Yes | Absolute path to the file | |
line_end | Yes | Ending line number (1-based) | |
line_start | Yes | Starting line number (1-based) | |
line_start_contents | Yes | Expected content of the starting line (used for verification) |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"contents": {
"description": "New content to replace the lines with",
"type": "string"
},
"file_path": {
"description": "Absolute path to the file",
"type": "string"
},
"line_end": {
"description": "Ending line number (1-based)",
"exclusiveMinimum": 0,
"type": "integer"
},
"line_start": {
"description": "Starting line number (1-based)",
"exclusiveMinimum": 0,
"type": "integer"
},
"line_start_contents": {
"description": "Expected content of the starting line (used for verification)",
"type": "string"
}
},
"required": [
"file_path",
"line_start",
"line_end",
"line_start_contents",
"contents"
],
"type": "object"
}