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

相关推荐
星辰徐哥11 小时前
鸿蒙平台 KDevelop 集成开发环境适配实战:基于 Electron 壳方案的跨平台多语言代码编辑器开发
electron·编辑器·harmonyos
风华同学19 小时前
vscode远程连接
ide·vscode·编辑器
sunoo-22920 小时前
【嵌入式 ARM 学习第十二天】SPI 裸机驱动 + I2C 触摸屏驱动 + 三大串行协议深度对比
arm开发·笔记·vscode·学习·imx6ull
kiss strong21 小时前
idea显示前进后退按钮
java·ide·intellij-idea
ShuiShenHuoLe1 天前
Visual Studio 2022 Community 下载指南
ide·visual studio
Sunny_GMF1 天前
所见即所得编辑器原理实战:源码与渲染永不失真的三层一致性设计(Markdown/CodeMirror 装饰)
microsoft·编辑器·ai编程·harmonyos
一路向北he1 天前
trae或者vscode定义了文件,但是文件不亮是灰的
ide·vscode·编辑器
bro_Java6662 天前
《栈与队列:数据结构的“双生花”》
java·数据结构·编辑器
u0111026752 天前
网页图片编辑器如何添加文字:字体、换行与导出一致性
图像处理·人工智能·ai作画·编辑器
Pointer Pursuit2 天前
编辑器Vim
linux·编辑器·vim