Apply a sequence of exact-match text replacements to a file.
Usage
tool_multi_edit(path, edits)
Arguments
- path
Path to the file to edit (tool argument)
- edits
List or JSON string of edit operations (tool argument)
Value
When called directly, a character status message describing the
edits and total replacement count.
Examples
path <- tempfile(fileext = ".txt")
writeLines(c("alpha", "beta"), path)
tool_multi_edit(
path,
list(list(old_text = "alpha", new_text = "gamma"))
)
#> [1] "Successfully applied 1 edit(s) to /tmp/RtmpJxzN8D/file1b545d2a38e8.txt (1 total replacement)"
unlink(path)