Skip to content

Configuration

Configure though the settings UI (Preferences: Open Settings (UI) > Rewrap section) where possible, or add them to your user or workspace settings file.

All settings can be set per language/file type (see below).

Summary

Setting Json ID Values (default first)
Auto Wrap: Enabled rewrap.autoWrap.enabled false | true
Auto Wrap: Notification rewrap.autoWrap.notification "icon" | "text"
Double Sentence Spacing rewrap.doubleSentenceSpacing false | true
Whole Comment rewrap.wholeComment true | false
Wrapping Column rewrap.wrappingColumn <number>

Wrapping column

The recommended way to set a wrapping column is to use a ruler (see below), which also gives a visual indication. If you don't want to do that, then you can use the Wrapping Column setting. This takes precedence over other options.

{
  // Wraps after 72 characters
  "rewrap.wrappingColumn": 72
}

If neither this nor any rulers are set, then VS Code's editor.wordWrapColumn setting is used. This has a default of 80.

Wrapping to rulers

To enable wrapping to rulers, rewrap.wrappingColumn must not be set.

If you have a ruler set up in VS Code, Rewrap will wrap to that ruler. If you have multiple rulers, you can choose which ruler to wrap to while editing.

cycles through rulers

Just press Alt+Q multiple times to wrap to each ruler in turn. The ruler chosen is then remembered for that document for the rest of the session. It cycles through the rulers in the order in which they appear in settings; so if you have a most commonly used ruler, you probably want to put that first.

Whole Comment

"rewrap.wholeComment": true`

When this is true, Rewrap will wrap a whole comment block when a text cursor is inside it.

wholeComment: true

But when set to false, Rewrap will only wrap that paragraph within the comment.

wholeComment: false

(Here the second paragraph is not wrapped)

Note: This setting only affects empty selections. You can always manually select the lines to wrap.

Double Sentence Spacing

  "rewrap.doubleSentenceSpacing": false

If enabled, whenever a paragraph is wrapped, for any lines that end in ".", "?" or "!", two spaces will be added after that sentence when the paragraph is rewrapped. This is not enabled by default.

(details)

Auto-wrap

Auto-wrap works like the auto-fill mode in Emacs. When pressing <space> or <enter> after the cursor is past the wrapping column, that line is wrapped onto the next.

Auto-wrap

Like in the Emacs function, auto-wrap does not attempt to re-flow the entire paragraph; it only adds a break in the current line. It's handy when typing new text, but won't automatically fix a paragraph after inserting/removing text. For this you can always do a standard alt+q after making edits.

Enabling

Auto-wrap is disabled by default, but can be enabled with the Rewrap > Auto Wrap: Enabled setting. This setting (rewrap.autoWrap.enabled) can also be set per language/document type .

Even when enabled, it will only activate within comments in code files, not on code lines, so it's usually ok to leave it enabled.

To temporarily enable or disable auto-wrap for the current document, you can use the Rewrap: Toggle Auto-Wrap command in the command palette.

Toggle Auto-wrap command

There's no default keybinding for the toggle command, but you can add one, eg shift+alt+q, by binding to the command ID rewrap.toggleAutoWrap in the Keyboard Shortcuts editor.

Notification

To help keep track of when auto-wrap is on or off, there is a small (optional, but on by default) icon/notification in the right of the statusbar, that shows the auto-wrap state for the current document. It has 4 states:

normal (normal) on (enabled in settings)
hidden (hidden) off (disabled in settings)
orange (orange) temporarily enabled (from toggle command)
gray (gray) temporarily disabled (from toggle command)

Hovering over this icon will give more information.

If you don't like the icon, you can hide it, or change the Rewrap > AutoWrap: Notification setting to "text". Then it will instead show a brief text message in the status bar for a few seconds whenever auto-wrap is toggled on or off.

Auto-wrap

Language-specific settings

See also the VS Code documentation.

This example sets the wrapping at column 72 for Python, with doubleSentenceSpacing on, and the wrapping column at 90 for Javascript.

{
  "[python]": {
    "editor.rulers": [72, 79],
    "rewrap.doubleSentenceSpacing": true
  },

  "[javascript]": {
    "editor.rulers": [90]
  }
}

VS Code has a helper command for adding language sections to your settings file: press F1 and search for Preferences: Configure Language Specific Settings....

Note: Be aware that a global rewrap.wrappingColumn setting will take precedence over a language-specific editor.rulers setting.

Keybindings

Rewrap's main command has the default keybinding Alt+Q. If you want to change it to something else, add something like this to your keybindings.json file. For example for Ctrl+Shift+Q:

{
  "key": "ctrl+shift+q", "command": "rewrap.rewrapComment"
}

There are two other commands you can add keybindings for (eg alt+shift+q):

Command ID
"Wrap Comment / Text at column..." rewrap.rewrapCommentAt
"Toggle Auto-Wrap for Current Document" rewrap.toggleAutoWrap