![](/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.