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
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