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

trim

Trim a character vector


Description

This trims a character vector according to the trimming rules used by glue. These follow similar rules to Python Docstrings, with the following features.

  • Leading and trailing whitespace from the first and last lines is removed.

  • A uniform amount of indentation is stripped from the second line on, equal to the minimum indentation of all non-blank lines after the first.

  • Lines can be continued across newlines by using \\.

Usage

trim(x)

Arguments

x

A character vector to trim.

Examples

glue("
    A formatted string
    Can have multiple lines
      with additional indention preserved
    ")

glue("
  \\ntrailing or leading newlines can be added explicitly\\n
  ")

glue("
    A formatted string \\
    can also be on a \\
    single line
    ")

glue

Interpreted String Literals

v1.4.2
MIT + file LICENSE
Authors
Jim Hester [aut, cre]
Initial release

We don't support your browser anymore

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