bulk_replace: Bulk replace a pattern throughout multiple files.

Description Usage Arguments Examples

View source: R/bulk_replace.R

Description

This function makes it easier to change a specific text string throughout a number of files, allowing you to ensure you're correcting all areas of your code at once.

Usage

1
bulk_replace(files, pattern, replacement, dry.run = TRUE)

Arguments

files

A vector of filepaths to replace strings in.

pattern

The character string to be replaced.

replacement

A character string to replace all patterns with.

dry.run

Logical – describe the file changes that will be made (TRUE) or make them in the specified files (FALSE)?

Examples

1
2
3
4
5
6
library(heddlr)
temp_file <- tempfile("test", fileext = ".Rmd")
temp_patt <- "#"
export_template(temp_patt, temp_file)
bulk_replace(c(temp_file), "#", "##")
bulk_replace(c(temp_file), "#", "##", dry.run = FALSE)

heddlr documentation built on March 24, 2020, 9:07 a.m.