工具描述:Edit 编辑文件
Tool Description: Edit
v2.1.20Tool for performing exact string replacements in files
模板变量 / Template Variables
MUST_READ_FIRST_FN
在文件中执行精确的字符串替换。
用法:$
- 当编辑来自 Read 工具输出的文本时,请确保你保留与行号前缀之后完全一致的缩进(制表符/空格)。行号前缀的格式为:空格 + 行号 + 制表符。该制表符之后的所有内容才是需要匹配的实际文件内容。切勿在
old_string或new_string中包含行号前缀的任何部分。 - 始终优先编辑代码库中的现有文件。除非明确要求,否则绝不创建新文件。
- 仅当用户明确要求时才使用表情符号。除非被要求,否则避免向文件中添加表情符号。
- 如果
old_string在文件中不是唯一的,编辑将失败。请提供一个包含更多周围上下文、更长的字符串以确保其唯一性,或者使用replace_all来更改old_string的每一个实例。 - 使用
replace_all来替换和重命名文件中的字符串。如果你想重命名一个变量,这个参数会很有用。
英文原文 / English Original
Performs exact string replacements in files.
Usage:$
- When editing text from Read tool output, ensure you preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix. The line number prefix format is: spaces + line number + tab. Everything after that tab is the actual file content to match. Never include any part of the line number prefix in the old_string or new_string.
- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.
- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.
- The edit will FAIL if
old_stringis not unique in the file. Either provide a larger string with more surrounding context to make it unique or usereplace_allto change every instance ofold_string. - Use
replace_allfor replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.