vscode 打开 setting.json

  1. 按下Ctrl + Shift + P(Windows/Linux)或Cmd + Shift + P(Mac)来打开命令面板。
  2. 输入open settings,然后选择 Open User Settings(JSON)。打开settings.json文件

------修改设置-----:

1、 html代码的行长度, 避免格式化时换行

html 复制代码
"editor.wordWrap": "on",
"editor.wordWrapColumn": 2000, // 设置为你想要的最大行长度


"html.format.wrapAttributes": "auto",  
"html.format.wrapLineLength": 2000, // 设置为你想要的最大行长度

Formatting

To improve the formatting of your HTML source code, you can use the Format Document command ⇧⌥F to format the entire file or Format Selection ⌘K ⌘F to just format the selected text.

The HTML formatter is based on js-beautify. The formatting options offered by that library are surfaced in the VS Code settings:

  • html.format.wrapLineLength: Maximum amount of characters per line.
  • html.format.unformatted: List of tags that shouldn't be reformatted.
  • html.format.contentUnformatted: List of tags, comma separated, where the content shouldn't be reformatted.
  • html.format.extraLiners: List of tags that should have an extra newline before them.
  • html.format.preserveNewLines: Whether existing line breaks before elements should be preserved.
  • html.format.maxPreserveNewLines: Maximum number of line breaks to be preserved in one chunk.
  • html.format.indentInnerHtml: Indent <head> and <body> sections.
  • html.format.wrapAttributes: Wrapping strategy for attributes:
    • auto: Wrap when the line length is exceeded
    • force: Wrap all attributes, except first
    • force-aligned: Wrap all attributes, except first, and align attributes 强制所有属性对其
    • force-expand-multiline: Wrap all attributes
    • aligned-multiple: Wrap when line length is exceeded, align attributes vertically
    • preserve: Preserve wrapping of attributes
    • preserve-aligned: Preserve wrapping of attributes but align
  • html.format.wrapAttributesIndentSize: Alignment size when using force aligned and aligned multiple in html.format.wrapAttributes or null to use the default indent size.
  • html.format.templating: Honor django, erb, handlebars and php templating language tags.
  • html.format.unformattedContentDelimiter: Keep text content together between this string.

Tip: The formatter doesn't format the tags listed in the html.format.unformatted and html.format.contentUnformatted settings. Embedded JavaScript is formatted unless 'script' tags are excluded.

The Marketplace has several alternative formatters to choose from. If you want to use a different formatter, define "html.format.enable": false in your settings to turn off the built-in formatter.

想见 HTML Programming with Visual Studio Code

相关推荐
HIT_Weston14 小时前
16、【Ubuntu】【VSCode】VSCode 断联问题分析:问题解决
linux·vscode·ubuntu
Trouville0114 小时前
如何在VScode环境下使用git进行版本控制,并上传到gitee远程仓库
ide·git·vscode
逐步前行14 小时前
C/C++图形库_EasyX 环境配置(VSCode+MinGW )
ide·vscode·编辑器
推理幻觉15 小时前
IDE/编码代理架构与 Cursor 相关研究(汇总)
ide·人工智能·架构·agent
正经教主15 小时前
【咨询】Android Studio 第三方手机模拟器对比【202511】
android·ide·android studio
名剑走天下17 小时前
在 VSCode 中:修改快捷键
ide·vscode·编辑器
名剑走天下17 小时前
在 VSCode 中:如何主动生成c_cpp_properties.json文件
ide·vscode·编辑器
扣得君17 小时前
解决glibc版本低VSCode无法远程问题
ide·vscode·编辑器·glibc升级·vscode远程glibc版本
Naiva18 小时前
【小技巧】PyCharm建立项目,VScode+CodeX+WindowsPowerShell开发Python pyQT6
vscode·python·pycharm
EEG小佬18 小时前
Jupyter选择内核时如何找到虚拟环境
ide·python·jupyter