【发布时间】:2019-09-30 09:31:23
【问题描述】:
当我的带有属性的元素变长时,VS Code 似乎会将行分成多行:
(我希望这里是三行而不是七行,每个元素一行)
我使用 prettier 进行格式化,并设置了 printWidth 选项,该选项适用于 javascript 代码,但对于 HTML,它似乎被 VS Code 覆盖。
我试过摆弄wrapAttributes 和html.format.wrapLineLength 设置,但这些设置似乎都没有任何效果。
这件事怎么处理?
更新:
非常感谢您的回答。他们没有通知我,很抱歉没有采取行动。
我已经尝试了您的所有建议,但问题仍然存在。 这是根据您的建议我目前的配置。
settings.json:
"html.format.wrapLineLength": 0,
"html.format.enable": false,
"html.format.wrapAttributes": "auto",
"vetur.format.defaultFormatterOptions": {
"prettyhtml": {
"printWidth": 300,
"singleQuote": false,
"wrapAttributes": false,
"sortAttributes": false
}
}
.prettierrc.json:
{
"semi": true,
"trailingComma": "none",
"singleQuote": true,
"printWidth": 300,
"tabWidth": 2,
"useTabs": true,
"jsxBracketSameLine": true
}
【问题讨论】:
-
没有一个答案符合您的要求吗?
标签: html visual-studio-code vuejs2 formatting vetur