Co-authored-by: Alexis Tacnet <alexis@mistral.ai> Co-authored-by: Clément Drouin <clement.drouin@mistral.ai> Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com> Co-authored-by: Lucas Marandat <31749711+lucasmrdt@users.noreply.github.com> Co-authored-by: Maxime Dolores <maxime.dolores@ext.mistral.ai> Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai> Co-authored-by: Quentin <quentin.torroba@mistral.ai> Co-authored-by: Val <102326092+vdeva@users.noreply.github.com> Co-authored-by: Vincent G <10739306+VinceOPS@users.noreply.github.com> Co-authored-by: p.vezia <166131032+le-codeur-rapide@users.noreply.github.com> Co-authored-by: Hiba Chaabnia <Hiba-Chaabnia@users.noreply.github.com> Co-authored-by: Nikhil Bhima <nikhilbhima@users.noreply.github.com> Co-authored-by: Nkipohcs <Nkipohcs@users.noreply.github.com> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
1.5 KiB
1.5 KiB
Use edit to make exact string replacements in files.
Arguments:
file_path: The path to the file to modifyold_string: The exact text to find and replacenew_string: The replacement text (must differ from old_string)replace_all: Set totrueto replace all occurrences (default:false)
IMPORTANT:
- ALWAYS call
readon the target beforeedit. The on-disk content may have changed since you last saw it (user edits, prior tool calls, external processes). Operating on stale content will either fail the exact-match check or silently apply the edit to the wrong place. - The
old_stringmust match the file content exactly, including whitespace and indentation - When editing text from
readoutput, match only the content AFTER the line number prefix (the1→part is not in the file). Never include any part of the line number prefix in old_string or new_string. - If
old_stringappears multiple times, the edit will fail unlessreplace_allistrue. Either provide more surrounding context to uniquely identify the target, or setreplace_alltotrue. - Use
replace_allfor renaming variables or strings across the file - Prefer editing existing files over writing new ones
old_stringcannot be empty; usewrite_fileto create new files- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.
- If an
editfails because theold_stringwas not found, re-read the file before retrying — do not guess at variations.