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

相关推荐
yz_aiks6 小时前
IDEA终端配置oh-my-zsh实战:安装、插件与日常使用技巧
java·ide·intellij-idea
小yu学编程7 小时前
IDEA 2025版本中如何设置包层级结构
java·ide·intellij-idea·层级结构
YXWik67 小时前
CodeGraph安装及在idea的claude code插件中使用
java·ide·intellij-idea
wbc103155587 小时前
基于 VSCode + Icarus 的 Verilog 编译和仿真
ide·vscode·编辑器
weixin_452077647 小时前
oai compatible provider for copilot for deepseek UI界面设置
vscode·copilot
xiaobobo33308 小时前
vscode如何免秘钥登入Ubuntu
vscode·ssh·免秘钥登入·ubuntu虚拟机
似夜晓星辰8 小时前
Markdown文本编辑器Typora平替
编辑器·github
谷哥的小弟10 小时前
(最新版)VSCode安装图文详解教程
ide·vscode·编辑器·教程·前端开发·图文
xiaoliuliu1234510 小时前
LaTeX 2023 (TeX Live + TeXstudio) 安装与汉化教程 Windows版:自定义路径+编辑器配置指南
windows·编辑器
IOT.FIVE.NO.111 小时前
Codex+Vscode+Remote ssh+ 服务器自定义第三方API配置保姆级教程
ide·vscode·编辑器