How can I use tabs for indentation in IntelliJ IDEA?

Intellij IdeaIndentation

Intellij Idea Problem Overview


How can I use tabs instead of multiple spaces for indentation in IntelliJ IDEA 11.0?

I have "Use tab character" checked under "Code Style" > "General" > "Default Indent Options". And also tried to have "Smart tabs" checked, but it doesn't help.

From the documentation:

>If this check box is selected, tab characters are used:

> * On pressing the Tab key

  • For indentation
  • For code reformatting

>Otherwise, spaces are used instead of tabs.

Intellij Idea Solutions


Solution 1 - Intellij Idea

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

Substitute weapon of choice for Java as required.

Solution 2 - Intellij Idea

###IntelliJ IDEA 15

###Only for the current file

You have the following options:

  1. Ctrl + Shift + A > write "tabs" > double click on "To Tabs"

To Tabs

If you want to convert tabs to spaces, you can write "spaces", then choose "To Spaces".

  1. Edit > Convert Indents > To Tabs

To convert tabs to spaces, you can chose "To Spaces" from the same place.

###For all files

The paths in the other answers were changed a little:

  • File > Settings... > Editor > Code Style > Java > Tabs and Indents > Use tab character Use tab character
  • File > Other Settings > Default Settings... > Editor > Code Style > Java > Tabs and Indents > Use tab character
  • File > Settings... > Editor > Code Style > Detect and use existing file indents for editing
  • File > Other Settings > Default Settings... > Editor > Code Style > Detect and use existing file indents for editing

It seems that it doesn't matter if you check/uncheck the box from Settings... or from Other Settings > Default Settings..., because the change from one window will be available in the other window.

The changes above will be applied for the new files, but if you want to change spaces to tabs in an existing file, then you should format the file by pressing Ctrl + Alt + L.

Solution 3 - Intellij Idea

I have started using IntelliJ IDEA Community Edition version 12.1.3 and I found the setting in the following place: -

File > Other Settings > Default Settings > {choose from Code Style dropdown}

Solution 4 - Intellij Idea

For anyone not able to get this, another thing you need to uncheck the following as well

Preferences > Editor > Code Style
[] Enable EditorConfig support
EditorConfig may override the IDE code style settings

My IntelliJ version 15.0.4

Solution 5 - Intellij Idea

Another useful option in IDEA to switch off or keep checked if you really need that:

Preferences -> Code Style -> Detect and use existing file indents for editing

if your team is going to switch to tab formatting with existing code written with spaces, uncheck that

Solution 6 - Intellij Idea

Have you tried .editorconfig? You can create this file in the root of your project and configure indentation for different file types. Your code will be automatically formatted. Here's the example:

# top-most EditorConfig file
root = true

# matches all files
[*]
indent_style = tab
indent_size = 4

# only json
[*.json]
indent_style = space
indent_size = 2

Solution 7 - Intellij Idea

My Intellij version is 13.4.1

Intellij IDEA->Perference->Code Style(Project Setting)

Solution 8 - Intellij Idea

To expand on @Dmitiri Algazin 's answer: settings for individual languages are overridden by the general setting

Preferences -> Code Style -> Detect and use existing file indents for editing

So if you are wondering why your new settings are being ignored after changing your settings for a specific language, there is a chance this checkbox is ticked.

As a side note; changing any default settings automamagically creates a settings profile clone (i.e. Default(1)) which I assume is in place so that the default IDE settings are never overwritten.

It is a little confusing at first, really, whether editing Default settings or Project Settings is going to have any effect on your project, since you can select Default from the drop down menu and then edit from there.

If you don't want to keep seeing random clones of Default populating your settings profiles, edit the Project Settings directly.

Solution 9 - Intellij Idea

For those who are having trouble indenting phpstorm here I have a tip and I hope they help ...

First you have to go to file-> settings-> keymap-> select-> windows. enter image description here enter image description here

If they are on the windows machine. If you are on mac and choose macos.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJonasView Question on Stackoverflow
Solution 1 - Intellij IdeaPaweł ObrokView Answer on Stackoverflow
Solution 2 - Intellij IdeaROMANIA_engineerView Answer on Stackoverflow
Solution 3 - Intellij IdeaBenView Answer on Stackoverflow
Solution 4 - Intellij IdeavisheshdView Answer on Stackoverflow
Solution 5 - Intellij IdeaDmitri AlgazinView Answer on Stackoverflow
Solution 6 - Intellij IdeavepanimasView Answer on Stackoverflow
Solution 7 - Intellij IdeaHaimeiView Answer on Stackoverflow
Solution 8 - Intellij IdeaGrayedFoxView Answer on Stackoverflow
Solution 9 - Intellij IdeaFaisca CiclismoView Answer on Stackoverflow