xurei
xurei

Reputation: 1086

IntelliJ - Tab indentation in Javascript does not work

I want to use tabs for indentation in my Javascript files. I changed the configuration as usual, but the preview doesn't seem to take my modification in account. Neither in the acutal files.

What is surprising is that the "Spaces" subtab is formatting the code the right way, but it's is the only place where it works. (See screenshots below)

Did anyone have the same issue ?

I am using IntelliJ Ultimate 2016.1

Config page (borken preview)

Spaces subtab (working preview)

Upvotes: 2

Views: 1782

Answers (2)

CESCO
CESCO

Reputation: 7768

Take a look a editorconfig.org . You will need a .editorconfig file at the root of your project. It's a markup file that works accros multiple IDE's to set some common configuration like indentation and trailing spaces. Here is an example.

root = true

[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true

[*.js]
indent_size = 2

Upvotes: 5

Vojtech Ruzicka
Vojtech Ruzicka

Reputation: 17105

From Intellij Idea 14 onwards, IDE by default detects existing indentation styles in existing files and uses them instead of your settings. You can Turn this feature off in the prefferences:

Prefferences -> Editor -> Code Style -> Detect and use existing file indents for editing

enter image description here

If turning off this feature does not help, make sure your project does not have .editorconfig file, which defines indentation styles as well.

Upvotes: 4

Related Questions