Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>RStudio Comment ReflowNew to Visual Studio Code? Get it now.
RStudio Comment Reflow

RStudio Comment Reflow

Angelo D'Ambrosio

|
1,579 installs
| (0) | Free
RStudio-style comment reflow functionality for VS Code
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

RStudio Comment Reflow for VS Code

This extension brings RStudio's comment reflow functionality to Visual Studio Code. It provides intelligent comment reflowing that respects Roxygen documentation, markdown code blocks, and bullet points.

This extension adapts code from Posit RStudio, implementing their comment reflow functionality for VS Code users.

Features

  • Reflows comments to fit within the editor's word wrap column width
  • Preserves Roxygen documentation tags and formatting
  • Handles markdown code blocks (```) without reflowing their contents
  • Preserves bullet points and lists
  • Supports multiple programming languages (R, Python, TypeScript/JavaScript, and more)
  • Maintains original comment indentation and prefixes

Usage

  1. Place your cursor inside a comment block or select multiple comment lines
  2. Press Ctrl+Shift+'
  3. The comment will be reflowed to fit within your editor's word wrap column

Configuration

The extension uses VS Code's editor.wordWrapColumn setting to determine the maximum line length. You can adjust this in your VS Code settings:

{
    "editor.wordWrapColumn": 80
}

Supported Comment Types

  • R/Python style comments (#)
  • JavaScript/TypeScript style comments (// and /* */)
  • Roxygen documentation (@tags)
  • Markdown code blocks
  • Bullet points (- and *)

Examples

Basic Comment Reflow

Before:

# This is a very long comment that exceeds the word wrap column and needs to be reflowed to make it more readable and conform to the specified width limit.

After:

# This is a very long comment that exceeds the word wrap column and needs to be
# reflowed to make it more readable and conform to the specified width limit.

Roxygen Documentation

Before:

#' @param x A very long parameter description that exceeds the word wrap column and needs to be reflowed while preserving the Roxygen tag formatting.
#' @return Another long description that needs to be reflowed while maintaining proper documentation structure.

After:

#' @param x A very long parameter description that exceeds the word wrap column
#'   and needs to be reflowed while preserving the Roxygen tag formatting.
#' 
#' @return Another long description that needs to be reflowed while maintaining
#'   proper documentation structure.

Installation

From VS Code Marketplace (Recommended)

  1. Open VS Code
  2. Press Cmd+Shift+X (Mac) or Ctrl+Shift+X (Windows/Linux) to open the Extensions view
  3. Search for "RStudio Comment Reflow"
  4. Click Install
  5. Reload VS Code when prompted

Manual Installation

  1. Download the latest .vsix file from the releases page
  2. Open VS Code
  3. Press Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux) to open the Command Palette
  4. Type "Install from VSIX" and select the command
  5. Navigate to the downloaded .vsix file and select it
  6. Then use Cmd+Shift+P or Ctrl+Shift+P and type "Reload Window" to reload VS Code

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This extension is licensed under the GNU Affero General Public License version 3 (AGPL-3.0). This is the same license used by RStudio, from which this extension adapts code.

The complete license text can be found in the LICENSE file. Additional attribution information is available in the NOTICE file.

Acknowledgments

This extension adapts code from Posit RStudio. The comment reflow functionality is based on RStudio's implementation, and portions of the code are Copyright (C) Posit Software, PBC (formerly RStudio).

The original RStudio implementation can be found at:

  • Repository: https://github.com/rstudio/rstudio/
  • License: AGPL v3
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft