Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

reindention

Specify what is re-indented how


Description

This function returns a list that can be used as an input for the argument reindention of the function tidyverse_style(). It features sensible defaults, so the user can specify deviations from them conveniently without the need of setting all arguments explicitly.

Usage

specify_reindention(regex_pattern = NULL, indention = 0, comments_only = TRUE)

tidyverse_reindention()

Arguments

regex_pattern

Character vector with regular expression patterns that are to be re-indented with spaces, NULL if no reindention needed.

indention

The indention tokens should have if they match regex_pattern.

comments_only

Whether the regex_reindention_pattern should only be matched against comments or against all tokens. Mainly added for performance.

Functions

  • specify_reindention: Allows to specify which tokens are reindented and how.

  • tidyverse_reindention: Simple forwarder to specify_reindention with reindention according to the tidyverse style guide.

Examples

style_text("a <- xyz", reindention = specify_reindention(
  regex_pattern = "xyz", indention = 4, comments_only = FALSE
))
style_text("a <- xyz", reindention = tidyverse_reindention())

styler

Non-Invasive Pretty Printing of R Code

v1.4.1
MIT + file LICENSE
Authors
Kirill Müller [aut], Lorenz Walthert [cre, aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.