![](/img/trans.png)
[英]How to prevent VS Code from putting '{' on new line in C++ formatting?
[英]Prevent new line in VS code after formatting
您需要安装Beautify插件并使用您需要的设置创建/编辑.jsbeautifyrc
文件。
VSCodeBeautify 文件设置在这里,其中包括 HTML 选项,请参阅:
Setting = 未格式化,Formatter = HTML,“a”表示链接。
所以安装插件,然后创建.jsbeautifyrc
文件并将其放在工作目录的根目录中:
{
"html": {
"unformatted": ["a"] // List of tags that should not be reformatted
}
}
VSCode 有以下设置:
// 标签列表,逗号分隔,不应重新格式化。 'null' 默认为https://www.w3.org/TR/html5/dom.html#phrasing-content中列出的所有标签。
"html.format.unformatted": "wbr",
// 标签列表,逗号分隔,内容不应重新格式化。 “null”默认为“pre”标签。
"html.format.contentUnformatted": "pre,code,textarea",
您想将 li 添加到第二个选项:
"html.format.contentUnformatted": "pre,code,textarea,li",
[或者,您可以关闭所有 html 格式,但您可能不希望这样做。]
// 启用/禁用默认 HTML 格式化程序
"html.format.enable": false,
如果您安装了扩展JS-CSS-HTML Formatter ,请将其卸载。
此扩展在保存时自动向<li>
添加新行。 它还有一个独立的配置文件,因此更改其他答案中提到的 vscode 内部设置不会解决由此引起的问题。
VSCode 默认不向<li>
添加任何新行
Go 到文件/首选项/设置并进行搜索:'formatSelectionAsHtml' 要使用的格式化程序:js-beautify(在我的情况下)每行最大字符数:9999
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.