An RStudio Addin to wrap paragraphs of RMarkdown text without inserting line breaks into inline R code.
You can install the plain version WrapRmd from GitHub with:
# install.packages("devtools")
devtools::install_github("tjmahr/WrapRmd")
This package used the commonmark package to wrap and reformat to markdown text. Using commonmark means that it can wrap links and markdown lists. The package does some additional work to handle inline R Markdown.
Here is some nice looking RMarkdown:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum a `r max(iris$Sepal.Length)`, viverra nisl at, luctus ante = `r length(letters) * 2 + 100`.
You highlight the text, and hit Ctrl/Cmd + Shift + /
to wrap the text and get:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum a `r
max(iris$Sepal.Length)`, viverra nisl at, luctus ante = `r length(letters) * 2 +
100`.
This RStudio Addin wraps text, but doesn't insert line breaks into inline R code, yielding:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum
a `r max(iris$Sepal.Length)`, viverra nisl at, luctus ante =
`r length(letters) * 2 + 100`.
Then go to Tools > Addins in RStudio to select and configure addins. I've mapped
this one addin to the shortcut Ctrl + Shift + Alt + /
.
Currently, the package wraps lines using a maximum line width of 80 characters.
It should work on multiple paragraphs: