Jo Liss
Jo Liss

Reputation: 32965

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.

Upvotes: 51

Views: 16817

Answers (2)

Captain Stack
Captain Stack

Reputation: 3824

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

Upvotes: 43

thedayturns
thedayturns

Reputation: 10833

VSCodeVim supports this feature. Just select a block of text and press gq. :)

Upvotes: 19

Related Questions