Edit file
edit_fileReplace an exact text string in a file to fix content issues. Requires precise match; use context or replaceAll for duplicates, and read the file first.
Instructions
Replace an exact string in an existing text file. The oldString must match the file content exactly, including whitespace and indentation. If oldString appears more than once, either add more surrounding context to make it unique or set replaceAll=true. Read the file first with read_file. The change is written to disk immediately and is not reversible. For several files or several changes at once, prefer patch so all edits succeed or none are applied.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Workspace-relative path of the file to edit. Absolute paths inside the workspace are also accepted. | |
| newString | Yes | Replacement text. Use an empty string to delete the matched text. | |
| oldString | Yes | Exact text to replace. Must not be empty. | |
| workspace | No | Workspace name (see workspace_list). Defaults to the primary workspace. | |
| replaceAll | No | Replace every occurrence instead of requiring a unique match. Defaults to false. |