edit_file_diff
Replace exact text snippets in files with new content, using precise matching to avoid unintended changes. Use empty string to delete text.
Instructions
Edit a file by replacing an exact text snippet with new content.
This is the preferred editing approach: send only the changed part instead of rewriting the whole file. The old_string must match exactly (whitespace, indentation) and should include enough context to be unique.
Raises ValueError if old_string is not found or found more/fewer times than expected_replacements.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the file to edit. | |
| old_string | Yes | Exact text to find in the file (must be unique or use expected_replacements). | |
| new_string | Yes | Replacement text. Use empty string to delete old_string. | |
| expected_replacements | No | Expected number of occurrences to replace. Default 1. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |