Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode Prettier formats HTML in an odd way (greater-than-symbol on next line)

Since today VSCode with installed Prettier Extension formats my HTML in a really odd way. For example:

<button
  class="btn btn-secondary mr-2"
  (click)="updateEditState(EditState.preview)"
  *ngIf="!(preview | async)"
>
  <ng-container i18n="AppPreviewEditButton|Enables the Preview mode of the page@@AppPreviewButton"
    >Preview</ng-container
  >
</button>
<button class="btn btn-secondary mr-2" (click)="updateEditState(EditState.edit)" *ngIf="!(edit | async)">
  <ng-container i18n="AppPreviewEditButton|Enables the Edit mode of the page@@AppEditButton"
    >Edit</ng-container
  >
</button>

Notice the > on new lines. Did somebody else experienced the same and has a solution?

like image 442
Daniel Habenicht Avatar asked Nov 08 '18 14:11

Daniel Habenicht


2 Answers

You should set "htmlWhitespaceSensitivity": "ignore" in your project's .prettierrc file.

https://prettier.io/docs/en/options.html#html-whitespace-sensitivity

like image 83
Gábor Pankotay Avatar answered Oct 05 '22 01:10

Gábor Pankotay


Since the issue finally got resolved: You can now use bracketSameLine: true in the prettier settings to control the behaviour.

like image 36
Daniel Habenicht Avatar answered Oct 05 '22 01:10

Daniel Habenicht