首页 文章

格式化后阻止VS代码中的新行

提问于
浏览
3

我希望 a 标签位于 li 标签here的同一行 . 我需要在VS代码中更改什么设置来修复它 .

2 回答

  • 1

    您需要安装Beautify插件并使用所需的设置创建/编辑 .jsbeautifyrc 文件 .

    VSCodeBeautify file settings在这里包含HTML选项,请参阅:

    Setting = unformatted, Formatter = HTML, "a" for a link.

    所以安装插件,然后创建 .jsbeautifyrc 文件并将其放在工作目录的根目录中:

    {
        "html": {
            "unformatted": ["a"] // List of tags that should not be reformatted
        }
    }
    
  • 2

    VSCode具有以下设置:

    //标签列表,逗号分隔,不应重新格式化 . 'null'默认为https://www.w3.org/TR/html5/dom.html#phrasing-content中列出的所有标签 .

    "html.format.unformatted": "wbr",
    

    //标签列表,逗号分隔,不应重新格式化内容 . 'null'默认为'pre'标签 .

    "html.format.contentUnformatted": "pre,code,textarea",
    

    您想将li添加到第二个选项:

    "html.format.contentUnformatted": "pre,code,textarea,li",
    

    [或者你可以关闭所有的HTML格式,但你可能不希望这样 . ]

    //启用/禁用默认HTML格式化程序

    "html.format.enable": false,
    

相关问题