Blank lines between lines of code (or text) in R script - a single blank line (or two)

Hi All,

Blank lines are important to clean and readable code. A blank line helps visually separate blocks of code out.
How to insert a blank line between lines of code in R script ?
Eg.

line one
line two
line three
line four
line five

to something like:

line one

line two

line three

line four

line five

regards,

Simply by pressing "enter"!?

No, this is not what I meant, rather to select all code (or large piece of it) and then format it like in Word or with some add-in, maybe ?
Not by pressing Enter after each and every line.

Like this?

library(readr)
library(stringr)

R_code = read_file("YourScript.R")
R_code_new = str_replace_all(R_code, "\r\n", "\r\n\r\n")

write_file(R_code_new, "YourScript.R")

You can read in the code, replace all line breaks with 2 line breaks and save it again.

I was thinking about something very simple, like this:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.