Zander Rootman
Zander Rootman

Reputation: 2208

IntelliJ/WebStorm "Smart" Indenting / Tab on newline

So this seems like quite a trivial question. At the moment when declaring an object, and assigning values as such:

let object = {
    myValue: "some value" <--- Now typically here I would hit <comma> <enter>
}

What use to happen:

let object = {
    myValue: "some value",
    anotherValue: "some other value"
}

What is happening now:

let object = {
    myValue: "some value",
        anotherValue: "some other value" <--- What is with this additional tabspace?
}

It's driving me nuts, and it's such a weird and specific thing to explain, google to no avail!

Every time I declare object properties I have to <shift> <tab> this additional space or <backspace>. Seriously driving me nuts, completely destroys my grove. This has been included in the new WebStorm update (2017.2).

Where is the setting to change this? What do I call this?

Upvotes: 3

Views: 5558

Answers (1)

Zander Rootman
Zander Rootman

Reputation: 2208

I got it sorted. So it's very specific to the following conditions:

  1. You're editing a file that has x spaces on indents / tabs
  2. Your default indent / tab spacing is y

Webstorm, assumes you want to apply: y indent / tab spaces when hitting your tab key, or creating a newline on a tabbed / indented element. So it applies y indent spaces. But it also recognises that the file has x spaces per indent.

The result is, when you hit tab on a indented element, it will indent by x spaces and when you create a newline on a indented element, it indent by y spaces.

To change this, you can either configure Webstorm to tab by x spaces, or configure it's dynamic file tab / indent space detection.

To disable Indent / Tab Space detection File > Settings > Code Style | Indents Detection

To adjust tab / indent spacing File > Settings > Code Style > {Language}

Upvotes: 4

Related Questions