Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 663
Michal_Szulc Avatar asked Jan 08 '17 11:01

Michal_Szulc


People also ask

How do I view tabs and spaces in IntelliJ?

You can use Find Action with ⌘⇧A (macOS), or Ctrl+Shift+A (Windows/Linux), and then type in 'Show virtual space at the bottom of the file'.

How do I use multiple tabs in IntelliJ?

Split a single file into multiple tabsRight-click a tab and choose Split Right or Split Down. Choose Window | Editor Tabs | Split Right/Split Down from the main menu.

What does Ctrl Alt l do in IntelliJ?

If you choose Code | Reformat Code from the main menu or press Ctrl+Alt+L , IntelliJ IDEA tries to reformat the source code of the specified scope automatically. For more details on how to reformat, or exclude files from formatting, refer toReformat code.


1 Answers

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

like image 115
DimaSan Avatar answered Oct 04 '22 23:10

DimaSan