Skip to content

Tool: replace_text_in_file

Description: Replace exact occurrences of a given text in a file.

Argument Type Description
file_path str Path to the file to modify.
search_text str The exact text to search for (including indentation).
replacement_text str The text to replace with (including indentation).
replace_all bool If True, replace all occurrences; otherwise, only the first occurrence.
backup bool, optional If True, create a backup (.bak) before replacing. Defaults to False.
Returns str Status message, warning, or error message.

Example usage: replace_text_in_file(file_path="main.py", search_text="foo", replacement_text="bar", replace_all=True)


generated by janito.dev