Shortcut for changing tabs->spaces->tabs in IntelliJ IDEA

Michal_Szulc picture Michal_Szulc · Jan 8, 2017 · Viewed 31.3k times · Source

I know I can change indentation by:

File > Settings > Editor > Code Style > ANY_LANGUAGE > Tabs and Indents > Use tab character

but in my legacy project there is a mix of indents in different files. Is there any keyboard shortcut in IDE for changing spaces to tabs and vice versa? Or how can I set up one for all or specified language files?

Answer

DimaSan picture DimaSan · Jan 8, 2017

To toggle between tabs and spaces:

On the main menu, choose Edit → Convert Indents, and then choose To Spaces or To Tabs respectively. Read more about Changing Indentation.

You can quickly do the same with Navigating to Action menu by pressing Ctrl+Shift+A and type convert indents in the field:

enter image description here

If you want to set spaces indents by default, go to Settings → Editor → Code Style → Java, make sure the Use tab character checkbox is unchecked and set the Indent value:

enter image description here