How to disable auto changing tabs to spaces in the code in Intellij Idea?

Maksym Kartsev picture Maksym Kartsev · Mar 23, 2015 · Viewed 9.4k times · Source

How to disable auto changing tabs to spaces and removing empty lines, whitespaces in the sourcefiles after it opened?

In other words if the line contains tabs and spaces in one line Idea shouldn't change them. For example if file contains "-->-->....-->public void setAttribute();" Idea shouldn't change tabs to spaces or spaces to tabs. I can disable all autoformattig.

Answer

kugo2006 picture kugo2006 · May 4, 2017

To restate the problem, you want the editor to not affect the whitespace indentations. Spaces should remain spaces and tabs should remain tabs.

I'm having a similar problem. It looks like IntelliJ has this feature:

Settings > Editor > Code Style, Indents Detection section, Detect and use existing file indents for editing option

Unfortunately, I don't think I can get it to work as expected for myself (version 2016.3.6), but it seems to be working for others.

Here's the original jetbrains blog post about it.