Edit Code
edit_codeApply a targeted source-code edit by replacing an exact substring and leaving the rest unchanged; use it for existing-code changes instead of resending the whole item.
Instructions
Makes a targeted edit to an item's source code by replacing an exact substring, leaving everything else untouched. Reads the current code, replaces old_string with new_string, and writes it back — so you do not need to resend the whole item to change a few lines. old_string must match the existing code exactly (including whitespace and indentation) and, unless replace_all is true, must occur exactly once. Prefer this over set_code for edits to existing code. If old_string is missing or ambiguous nothing is written, and when the only difference is whitespace the error returns the exact text to retry with. Reaches the same items as get_code. The change stays in the IDE until save_project. Needs the Xojo IDE running with the project open.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"old_string": "<old_string>",
"new_string": "<new_string>"
},
"name": "edit_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| location | No | Dot-separated path (e.g. 'Module1.Method1'). Edits the current location if empty. | |
| new_string | Yes | Text to replace old_string with. | |
| old_string | Yes | Exact text to find. Must match the existing code verbatim, including whitespace and indentation. | |
| replace_all | No | Replace every occurrence. If false (default), old_string must occur exactly once. |