stib
stib

Reputation: 3522

How do I get VSCode to auto-indent this correctly?

I'm calling a function and I want the parameters to be on separate lines so I can comment them, like this:

doStuff(
    doItWell.quality,         // quality setting
    doItFast * 100,           // speed setting
    doItCheap.checkbox.value  //price setting
);
alert("done");

but VSCode auto-indent always does this:

doStuff(
    doItWell.quality,         // quality setting
    doItFast * 100,           // speed setting
    doItCheap.checkbox.value  //price setting
    );
    alert("done");

Note the extra indent on the alert() line.

Prettier gets it, so when I type it in and it auto-formats it's all good, but as soon as I run VSCode's auto-indent I get the extra indentation.

Upvotes: 1

Views: 1440

Answers (1)

AzuxirenLeadGuy
AzuxirenLeadGuy

Reputation: 2870

Prettier gets it, so when I type it in and it auto-formats it's all good, but as soon as I run VSCode's auto-indent I get the extra indentation.

So you basically need to set Prettier as the default formatted. Go to the settings (by Ctrl+,) and set "Editor: Default Formatter" to Prettier.

This will override your 'default' vscode formatter

Upvotes: 1

Related Questions