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
- Place your cursor inside a comment block or select multiple comment lines
- Press
Ctrl+Shift+'
- 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
}
- R/Python style comments (#)
- JavaScript/TypeScript style comments (// and /* */)
- Roxygen documentation (@tags)
- Markdown code blocks
- Bullet points (- and *)
Examples
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)
- Open VS Code
- Press
Cmd+Shift+X
(Mac) or Ctrl+Shift+X
(Windows/Linux) to open the Extensions view
- Search for "RStudio Comment Reflow"
- Click Install
- Reload VS Code when prompted
Manual Installation
- Download the latest
.vsix
file from the releases page
- Open VS Code
- Press
Cmd+Shift+P
(Mac) or Ctrl+Shift+P
(Windows/Linux) to open the Command Palette
- Type "Install from VSIX" and select the command
- Navigate to the downloaded
.vsix
file and select it
- 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: