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.
wordWrap": "on" You can toggle word wrap for the VS Code session with ⌥Z (Windows, Linux Alt+Z).
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.
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!
Looks like Rewrap does what you need. Not sure if there's a native way yet. They're still adding a lot of features.
VSCodeVim supports this feature. Just select a block of text and press gq
. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With