Let language extensions dynamically configure soft word wrap for long lines #234591
Description
VS Code currently offers a word wrap option, which breaks lines at a certain fixed length in the editor UI. This works fine, but is intended mainly for written text/comments/markdown and doesn't take language syntaxes into account. The feature isn't very highly used, probably by design.
There are also language-specific autoformatters that understand syntax and do hard line breaks. This is the better option for clearer and more understandable code, and so is very commonly used across most codebases (e.g. using Prettier and/or built-in linters). The drawback is that because the formatting changes are written to disk, the same line length setting must apply to everyone working in a repo regardless of their monitor size and personal preferences.
There's a possible solution that combines both of these by letting custom formatters provide both a hard break (\n
) and a soft break signal to the editor. The word wrap setting thus doesn't have to be static for the entire editor but can be automatically set per file and per line. The lines themselves can be arbitrarily long on disk, and each end user can configure their own view depending on their setup.
Additional advantages include:
- No surprise formatting of the entire file when changing one line because someone else committed without running the formatter.
- Significantly cleaner diffs.
- Fewer fights between devs working on the same codebase.
Activity