How to prevent VS Code from breaking up long HTML lines into multiple lines?

对着背影说爱祢 提交于 2020-01-14 15:54:31

问题


When my elements with attributes get long, VS Code seems to break the line up into multiple lines:

(I would like three lines here instead of seven, one line per element)

I am using prettier for formatting, and have set the printWidth option which works in javascript code, but for HTML it seems to be overridden by VS Code.

I´ve tried fiddling around with the wrapAttributes and the html.format.wrapLineLength settings, but none of those seem to have any effect.

How to deal with this matter?


回答1:


I'm not sure if it's just the built-in HTML formatting settings but you can give this a try.

If you don't want to enable wrapping for HTML:

"html.format.wrapAttributes": "auto",  # wrap only when line length is exceeded
"html.format.wrapLineLength": 0,       # disable max chars per line

If you have other HTML formatter extensions, you can simply disable the built-in:

"html.format.enable": false,

If your HTML is still breaking-up with the *.wrap disabled or with html.format.enable false, then it's not the built-in VS code settings that's causing it.




回答2:


You can add "html.format.wrapLineLength": 0 in settings.json.




回答3:


check your extension because i think VS code editor default don't have a auto break function. maybe you install a extension that have a auto break line. hope this help




回答4:


Settings -> Extensions -> HTML:
Format: Wrap Line Length
Maximum amount of characters per line (0 = disable).
0

That worked for me.



来源:https://stackoverflow.com/questions/56112054/how-to-prevent-vs-code-from-breaking-up-long-html-lines-into-multiple-lines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!