简体   繁体   中英

Prettier in VS code splitting attributes onto multiple lines ( print width doesn't work for html ) Angular

I've searched a lot about it and tried so much solutions,

I'm using Angular when formatting html with prettier it's quite ugly because it wraps every single attribute to a new line eg:

   <button
      pButton
      class="btn"
      type="button"
      label="Add Item(s)"
      (click)="handleClick()"
    ></button>
  • Print Width is 250 everywhere

在此处输入图像描述

  • added .prettierrc.json file with {"printWidth": 100}
  • Single Attribute Per Line isn't checked

在此处输入图像描述

Important thing to note is that prettier is applying printWidth 80 something like built-in because I'm sure that it's not set in any settings by user, I have some attributes that are two per line when they quite little in space eg:

 <div class="p-col-2" style="float: left">
     {{ "modules.user.orderdisplay.quantity" | translate }}
 </div>

You should also check for.editorconfig file - if it is present prettier will use it's values.

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