简体   繁体   English

我想在 VS Code 中格式化我的 html 代码

[英]I would like to format my html code in VS Code

my html code in my angular component, i automatically have:我的 angular 组件中的 html 代码,我自动拥有:

     <a
        class="text-sm font-bold leading-relaxed inline-block mr-4 py-2 whitespace-no-wrap uppercase text-white"
        href="#pablo"
      >
        pink Color
      </a>
      <button
        class="cursor-pointer text-xl leading-none px-3 py-1 border border-solid border-transparent rounded bg-transparent block lg:hidden outline-none focus:outline-none"
        type="button"
      >
        <span class="block relative w-6 h-px rounded-sm bg-white"></span>
        <span
          class="block relative w-6 h-px rounded-sm bg-white mt-1"
        ></span>
        <span
          class="block relative w-6 h-px rounded-sm bg-white mt-1"
        ></span>
      </button>

While I would like that:虽然我想这样:

      <a class="text-sm font-bold leading-relaxed inline-block mr-4 py-2 whitespace-no-wrap uppercase text-white" href="#pablo">
        pink Color
      </a>
      <button class="cursor-pointer text-xl leading-none px-3 py-1 border border-solid border-transparent rounded bg-transparent block lg:hidden outline-none focus:outline-none" type="button">
        <span class="block relative w-6 h-px rounded-sm bg-white"></span>
        <span class="block relative w-6 h-px rounded-sm bg-white mt-1"></span>
        <span class="block relative w-6 h-px rounded-sm bg-white mt-1"></span>
      </button>

I search on my settings.json but i don't know where i can't change that... Any Suggestions?我在我的 settings.json 上进行搜索,但我不知道在哪里无法更改...有什么建议吗?

For a better and current pattern, go in your extensions tab and download Prettier and ESLint.要获得更好和最新的模式,请在扩展选项卡中的 go 并下载 Prettier 和 ESLint。

So, in your settings you can add:因此,在您的设置中,您可以添加:

"[javascript, angular, html, css, json]": {
        "editor.formatOnSave": true
    },
    "eslint.quiet": true,
    "editor.codeActionsOnSave": {
        "eslint.autoFixOnSave": true,
    },

Or edit for any language you want to vscode act.或者编辑任何你想要 vscode 行为的语言。

This will make the code always as readable as possible regardless of the length of the code line.无论代码行的长度如何,这将使代码始终尽可能地可读。

I find the solution.我找到了解决方案。 Add this lines in settings.json在 settings.json 中添加这一行

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 VS Code 更改了我的 HTML 的默认格式 - VS Code changes the default format of my HTML 我想使用 HTML 和 JavaScript 执行 While 循环,但是使用我当前的代码循环并没有结束 - I would like to do a While loop using HTML and JavaScript however with my current code the loop is not ending 我希望我的代码只显示 2 位小数 - I would like my code to only show 2 decimal places 如何在 Ubuntu 上的 VS 代码中格式化 HTML 代码? - How to format HTML code in VS Code on Ubuntu? 我是编码新手。 我想在按下按钮后在我的 html 页面上的文本框中显示来自我的 javascript 文件的 java 代码结果 - I am new to coding. I would like to display my java code result from my javascript file in a text box on my html page after pressing a button 格式化HTML中的Java代码以使其像在IDE中一样显示 - Format java code in HTML to display it like in an IDE VS代码:自动格式化HTML不起作用 - VS Code: auto format html does not work 我想把这个代码块变成一个 keydown function 我可以从 html 表单调用 - I would like to turn this block of code into a keydown function that i could call from a html form 我想使用 html 代码作为背景。 我怎样才能做到这一点? - I would like to use html code as background. How can I do that? 带有html内容的工具提示出现在右侧,有工作代码,但仅适用于1个提示,我希望它是动态的 - Tooltip with html content that appears right side, got working code but it's only for 1 tip, i would like it to be dynamic
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM