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

相关推荐
oioihoii7 小时前
如何设置 Visual Studio 在调试停止时自动关闭控制台
ide·visual studio
曹申阳8 小时前
1. 使用VSCode开发uni-app环境搭建
ide·vscode·uni-app
大江东去浪淘尽千古风流人物9 小时前
【Wins】Visual Studio memory leak check使用教程
ide·visual studio
每天更新10 小时前
VSCODE 使用GDB
ide·vscode·编辑器
paoqi 包奇11 小时前
pycharm中使用anaconda指定虚拟环境
ide·python·pycharm
傅科摆 _ py12 小时前
解决 Vscode 中运行键突然消失的问题
ide·vscode·编辑器
丨Sky丨夜吻12 小时前
vscode扩展
ide·vue.js·vscode
慕伏白13 小时前
【慕伏白】Android Studio 无线调试配置
android·ide·android studio
阑梦清川13 小时前
vscode远程连接云服务器的初次尝试
vscode
yeziyfx18 小时前
Android Studio制作.9图(点9图/9Patch图)
android·ide·android studio