admin管理员组文章数量:1122846
I just have one question, currently I am using prettier and it formats on save but there are just things I don't understand that when I format the spaces or indetion are not equal. Is there a setting I don't know in VS Code ?. How do or what do we set to make it consistent ? Specially the spacing. Thank you.
For example, when I format some button formatted this way
#example 1
<button
(click)="delete()"
mat-button
color="primary"
[mat-dialog-close]="true"
>
Proceed
</button>
and sometimes when I format it is formatted this way
<button (click)="add()" mat-flat-button style="color: #007dff">
Submit
</button>
#Another example is this one i formatted this using prettier and as you can see it looks bad and the spacing is too much.
I just have one question, currently I am using prettier and it formats on save but there are just things I don't understand that when I format the spaces or indetion are not equal. Is there a setting I don't know in VS Code ?. How do or what do we set to make it consistent ? Specially the spacing. Thank you.
For example, when I format some button formatted this way
#example 1
<button
(click)="delete()"
mat-button
color="primary"
[mat-dialog-close]="true"
>
Proceed
</button>
and sometimes when I format it is formatted this way
<button (click)="add()" mat-flat-button style="color: #007dff">
Submit
</button>
#Another example is this one i formatted this using prettier and as you can see it looks bad and the spacing is too much.
Share Improve this question edited yesterday Peter Macej 5,53729 silver badges51 bronze badges asked yesterday Mr. Mark TawinMr. Mark Tawin 811 silver badge6 bronze badges 5 |1 Answer
Reset to default 1I was struggling to get around when I was getting started with Prettier as well. Here are some simple changes you can do to ensure you get what you are looking for:
- Keeping the JSX attributes on the same line- if you are looking for a cleaner way (the way your example is shown), keeping those attributes in a single line would make it look cleaner and much shorter. For this, you have to un-check Prettier: Single Attribute Per Line from your Settings -
- Change your Prettier Print Width to something like 1000.
This should work as you are expecting.
本文标签: htmlVS Code indention and prettierStack Overflow
版权声明:本文标题:html - VS Code indention and prettier - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736283664a1927037.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
<p>
tags. – Tim Roberts Commented yesterday