Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.
like image 850
Jo Liss Avatar asked Mar 20 '17 19:03

Jo Liss


People also ask

How do I unwrap text in VS Code?

wordWrap": "on" You can toggle word wrap for the VS Code session with ⌥Z (Windows, Linux Alt+Z).

How do you wrap text in VS Code?

If you want to use text word wrap in your Visual Studio Code editor, you have to press button Alt + Z for text word wrap.

What is toggle word wrap?

The phrasing of “Toggle Word Wrap” is descriptive, but it can sound confusing at a cursory glance. It simply takes any text that runs off the side of the screen and consolidates it within the window and a nicely formatted style!


2 Answers

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

like image 172
Captain Stack Avatar answered Oct 04 '22 04:10

Captain Stack


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

like image 34
thedayturns Avatar answered Oct 04 '22 04:10

thedayturns