msung
msung

Reputation: 3742

How to make IntelliJ indent wrapped condition in JavaScript if statement

When I have JavaScript-Code like this:

if(conditionOne &&
   conditionTwo) {
   doSomething();
}

JSLint complains

Expected 'conditionTwo' at column {n+4}, not column {n}.

Where n is the column where conditionOne and conditionTwo begin.

(How) can I configure IntelliJ to format my code this way instead?

if(conditionOne &&
       conditionTwo) {
   doSomething();
}

I did look in Settings -> Code Style -> JavaScript but did not find such an option (or did not recognize it).

Upvotes: 2

Views: 1161

Answers (1)

Jen S.
Jen S.

Reputation: 4234

You need to increase the "Continuation Indent" under Settings -> Code Style -> JavaScript

I set mine to 8 and it formats your block correctly.

Under the "Tabs and Indents" tab, I unchecked "Use tab character", Tab size is 4, Indent is 4, and Continuation indent is 8. Then it formats it according to your example.

Upvotes: 2

Related Questions