Reputation: 9
I want to be able to break up long lines of code for better readability, but every time I save the file, VS Code reformats it back into a single line. I want to retain auto-formatting of code because it makes indentation easy, but this inability to break it up into multiple lines is really beginning to bother me.
I toggled with wrapAttributes
and the html.format.wrapLineLength
settings to no avail.
How do I preserve/automatically break-up long lines of code?
PS: I use the Prettier extension, but could not identify any setting there that helped with this either.
Upvotes: 0
Views: 11427
Reputation: 11
VS Code has an auto-wrapping feature that wraps lines at a certain column width. This is useful when you're working with long lines of code or comments.
Press Alt + Z (Windows/Linux) or Option + Z (macOS) to toggle Word Wrap. This will automatically break long lines to fit within the editor window, making them easier to read without changing the code.
Upvotes: 1
Reputation: 81
As Wulolo said that is the way, if you want to use the shortcut for toggling wordWrap: Alt + Z.
Preview when its On:
Upvotes: 0
Reputation: 81
1- Opening the settings.
2- Search for "line length".
3- Set it to 2000.
Upvotes: 0
Reputation: 1
there is a similar question: What is the property name to break long lines in VS Code?
Opening the settings.
Search for "word wrap".
Set Editor: Word Wrap
on.
Upvotes: 0