简体   繁体   中英

VS Code HTML formatter that preserves inline comments

I'm trying to find a decent HTML formatter plugin for VS Code that won't "break" a lot of pre-existing HTML that has inline comments eg

<div>hello</div><!-- class="world" -->

Shouldn't turn into this:

<div>hello</div>
<!-- class="world" -->

Apparently jsbeautify is not good about this. I tried prettier and same issue..the comments would wrap. After a lot of digging I disabled everything but now I don't have basic auto-formatting of html tags to auto-indent etc.

If anyone has a good vs code setup that addresses this, would highly appreciate if you could share which plugin you're using and any associated plugin settings that may be required to preserve inline comment formatting.

Thanks,

  • S. Arora

In settings.json , add

 "[html]": {
        "editor.defaultFormatter": "vscode.html-language-features"
      },

From there, you can search for "whitespace" in the settings UI of VSCode, and configure as you like.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM