简体   繁体   中英

How to prevent a line break to every html element end tag using VSCode Prettier?

This what I currently have on my Editor. This is actually a laravel blade, so the filename is page.blade.php . However, I added these on the files.associate ;

"*.blade.php":"html"
<nav
    class="navbar navbar-standard navbar-expand-lg fixed-top navbar-dark navbar-theme"
>
    <div class="container">
        <a class="navbar-brand" href="../index.html"
            ><span class="text-white">{{ config("app.name") }}</span></a
        >
        <button
            class="navbar-toggler collapsed"
            type="button"
            data-toggle="collapse"
            data-target="#navbarStandard"
            aria-controls="navbarStandard"
            aria-expanded="false"
            aria-label="Toggle navigation"
        >
            <span class="navbar-toggler-icon"></span>
        </button>
    </div>
</nav>

So if you notice on the snippet, the > is always breaking the line and it's not good. especially on the </a> tag. I tried editing the HTML>Format: Wrapp Attributes , but it's not working, see picture attached:

vs代码设置

Now this is what I want.

<nav class="navbar navbar-standard navbar-expand-lg fixed-top navbar-dark navbar-theme">
    <div class="container">
        <a class="navbar-brand" href="../index.html">
            <span class="text-white">Logo</span>
        </a>
        <button class="navbar-toggler collapsed" type="button" data-toggle="collapse" data-target="#navbarStandard" aria-controls="navbarStandard" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
    </div>
</nav>

只需单击右下纯文本,它将打开一个对话框,输入 html 和 SELECT html

然后右键单击并选择格式文档。它会像你想要的那样格式化文件

Just click on Right bottom plain text, it will open a dialog box type html and Select HTML. see Picture 1.

Then right click and select format document. It will format file like you want. See Picture 2.

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