Remove blank line duplicates from a file
Source:R/remove_blank_line_dups.R
remove_blank_line_dups.Rd
This function removes blank line duplicates (e.g., a ""
line, followed by
another ""
line) from a file.
It can also remove blank lines at the top or bottom of the file, and remove blank lines around a text block.
Usage
remove_blank_line_dups(
file,
remove_caps = TRUE,
block_fix = TRUE,
block_start_pattern = "<!-- badges: start -->",
block_end_pattern = "<!-- badges: end -->"
)
Arguments
- file
A string indicating a file path.
- remove_caps
A
logical
flag indicating if the function should remove blank lines at the top and bottom of the file.- block_fix
A
logical
flag indicating if the function should fix blank lines around a text block- block_start_pattern
A string indicating the start of the text block.
- block_end_pattern
A string indicating the end of text block.
See also
Other file functions:
blank_line_neighbors()
,
normalize_hashtags()
,
normalize_names()
,
replace_in_file()
,
split_file()
Examples
file <- tempfile()
writeLines(c("", "line 1", "", "", "line 2", "", "", "line 3", ""), file)
remove_blank_line_dups(file)
readLines(file)
#> [1] "line 1" "" "line 2" "" "line 3"
#> [1] "line 1" "" "line 2" "" "line 3" # Expected