Sabbir Ahmed Saif
Sabbir Ahmed Saif

Reputation: 191

Prettier formats in multiline for arrays and long line in VSCode

When I use a long array and console, prettier formats it into multiple lines which is annoying in some cases. I want them break after a certain length. Can I set a breaking point for the prettier where it will make the new line? Please check the image. Prettier format demo

Upvotes: 16

Views: 17633

Answers (2)

tyirvine
tyirvine

Reputation: 2391

Edit: The extension is now deprecated unfortunately. ⤵︎

Old Answer

There's a fork of Prettier called Prettier Now that allows this.

After downloading, go into your settings.json and add ⤵︎

"prettier.arrayExpand": true

Upvotes: 2

Sadly can't be done, here you can find the discussion about the issue. The only apparently solution it's to add a comment // after the first array element:

Example:

imports: [
        BrowserModule, //
        FoodModule,
        SharedModule,
        AppRoutingModule
    ],

Upvotes: 15

Related Questions