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

相关推荐
佛曰我不想说话23 分钟前
在VSCode中使用Jupyter Notebook
ide·vscode·jupyter
万维——组态5 小时前
BY组态-低代码web可视化组件
前端·物联网·低代码·编辑器·流程图·组态
小豆豆儿8 小时前
【PyCharm】快捷键使用
ide·python·pycharm
rgrgrwfe8 小时前
【golang学习之旅】使用VScode安装配置Go开发环境
vscode·学习·golang
小豆豆儿15 小时前
【PyCharm】远程连接Linux服务器
ide·python·pycharm
一只爬爬虫15 小时前
pycharm+pyside6+desinger实现查询汉字笔顺GIF动图
ide·python·pycharm·designer·pyside6·gif动图·汉字笔顺
小豆豆儿16 小时前
【PyCharm】连接Jupyter Notebook
ide·jupyter·pycharm
三月的船长19 小时前
Android Studio常用操作备忘录
android·ide·android studio
2401_882727971 天前
web组态可视化编辑器
前端·后端·物联网·低代码·编辑器
莲动渔舟1 天前
国产编辑器EverEdit - 列编辑模式
编辑器·notepad++·emeditor·everedit