Home > database >  IntelliJ IDEA: Unnecessary space after reformatting
IntelliJ IDEA: Unnecessary space after reformatting

Time:05-22

I'm new to IntelliJ and need some help for some issue when I'm reformatting the code.

For example, let's say I have this code which is ,at first, written in other IDE(Eclipse).

@Service
public class TestService {
    private Logger logger = LoggerFactory.getLogger(getClass());
    //...
}

If I reformat code(cmd option L)...

@Service
public class TestService {
____private Logger logger = LoggerFactory.getLogger(getClass());
    //...
}

IntelliJ somehow generates some silly empty spaces that make git to think something changed.

I'm currently using the most recent version of IntellJ on M1 Mac. I also did import Eclipse code style into IntelliJ. Is there any configuration to resolve this problem?

CodePudding user response:

Probably your tab characters were auto-replaced by space characters because that is IntelliJ defaults.

Go to "Preferences | Editor | Code Style | Java" and click "Use tab character" to keep your tabs.

  • Related