Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>R FormatterNew to Visual Studio Code? Get it now.
R Formatter

R Formatter

thisisamirv

|
2 installs
| (1) | Free
Format R source files in VS Code.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

R Formatter

CI VS Code Marketplace

R Formatter is a VS Code extension that formats R source files using the styler package. It integrates with VS Code's built-in format-on-save and Format Document commands.

Features

  • Format .R, .r, .Rmd, and .rmd files using styler::style_file().
  • Checks for R and styler on startup and offers to install styler if missing.
  • Configurable formatting scope: spaces, indentation, line breaks, or full token-level changes.
  • Configurable indentation width, line length, strict mode, roxygen example formatting, and comment spacing.
  • Works with VS Code's Format Document, Format on Save, and format-on-type features.
  • Supports a custom Rscript path for non-standard R installations.

Requirements

  • R must be installed and Rscript must be on PATH (or configured via the r-formatter.rscriptPath setting).
  • The styler R package must be installed. If it is missing, the extension will prompt you to install it automatically on startup.

To install styler manually, run in R:

install.packages("styler")

Settings

Setting Default Description
r-formatter.rscriptPath "Rscript" Path to the Rscript executable.
r-formatter.scope "tokens" How invasive the formatter is: none, spaces, indention, line_breaks, or tokens.
r-formatter.strict true Forces exactly one space or line break where required.
r-formatter.indentBy 2 Number of spaces per indentation level.
r-formatter.lineLength 80 Target line length (sets R's width option before formatting).
r-formatter.includeRoxygenExamples true Format code inside @examples roxygen blocks.
r-formatter.startCommentsWithOneSpace false Enforce a single space after # in comments.

Installation

The extension is available on the VS Code Marketplace.

For development, testing, and packaging instructions, see DEVELOPMENT.md.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft