RewrapsHard word wrapping for comments and prose, at the column you choose. Put the cursor in a comment — or select text — and run Rewraps: Wrap Selection or Comment from the command palette. The text is re-flowed to your column and the comment markers are put back. It also wraps Markdown files, plain text, and the inside of block comments, docstrings included. Credit where it is dueRewraps is an independent, from-scratch implementation inspired by Rewrap by Steve Baker, which has done this job well for VS Code and Visual Studio for years and whose documentation is the best description of the problem that exists. No code or files from Rewrap are included here. None of its source, its test specifications or its data tables were copied; everything in this repository was written for it. The overlap you can see — the same comment markers, the same ideas about what must not be re-flowed — is the overlap of two implementations of the same problem, not shared text. Where this behaves differently from Rewrap, that is a deliberate choice, not an accident; see Not the same as Rewrap. Using it
There is no default key binding — nothing is taken from you. To add one,
open Keyboard Shortcuts, search for
Where the column comes fromRewraps reads
If no ruler is set for the file, the first explicit wrap asks for a column and remembers the answer for that language. There is no guessed default: wrapping at a column nobody chose is how text ends up at 80 by accident. Dismissing that prompt does nothing at all — no wrap, no default. Auto-wrap never asks and never guesses: with no ruler for the file it does nothing, and an explicit wrap asks instead. When you type a word past the column, the text moves to the next line and the cursor goes with it — it ends up after the word it pushed down, not stranded at the end of the line that just got shorter. Auto-wrapAuto-wrap defaults to on. It fires only when you type whitespace that pushes the current line past the column — not on paste, undo, or a multi-cursor edit, because an automatic rewrite that guesses wrong fights your undo history. The status bar shows whether it is on for the open file; the toggle command overrides the setting per file. Not the same as Rewrap
Supported languages57 languages, each with fixtures: Ada, Batch, C, C#, C++, CMake, CSS, Clojure, Common Lisp, D, Dockerfile, Elixir, Elm, F#, Go, GraphQL, Groovy, HTML, Haskell, INI, JSON, Java, Julia, Kotlin, LaTeX, Less, Lua, MATLAB, Makefile, Markdown, OCaml, Objective-C, PHP, Perl, PlainText, PowerShell, Prolog, Protobuf, PureScript, Python, R, Ruby, Rust, SCSS, SQL, Scala, Scheme, Shell, Svelte, Swift, TOML, TypeScript, Verilog, Vue, XAML, XML, YAML.
A file whose language is not in the table is treated as plain text: its paragraphs are wrapped and nothing else is touched. An unknown language never damages a file; it just does less. Adding a languageAdding one is data, not code — that is a hard rule of the design, enforced by a test that fails if a language name appears in the engine at all.
The build validates the file: two languages claiming one extension, a dialect that does not exist, a string comment with no single-line policy, or a marker that another shadows all fail the build rather than producing an editor that looks like it works. The command lineThe same engine, for scripts, editor plugins and pre-commit hooks:
Development
Checking the engine against a real corpus
The corpus is Rewrap's published specification, cloned at run time into a temporary directory — none of it is stored here:
Nothing generated is committed: the wasm module and the bundled extension are produced by the build, here and in CI. The layout:
LicenceAGPL-3.0-only. See LICENSE. |