visual-studio-code

VS Code: Rewrap block of text or comment


How do I rewrap a block of text or a long comment to fit 80 columns?

I don't want it to just render the word wrap (this is easily achieved with Edit -> Toggle Word Wrap or setting "editor.wordWrap": "on"), but I want it to actually insert hard line breaks. This feature is called "fill paragraph" in some editors.

For example:

// This is a very long comment. I would like for this comment to occupy multiple lines rather than a single line, so that it is easy to read for other people.

Now I'd like to press some key to get:

// This is a very long comment. I would like for this comment to occupy
// multiple lines rather than a single line, so that it is easy to read for
// other people.

Solution

  • Looks like Rewrap does what you need. Not sure if there's a native way yet. They're still adding a lot of features.