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.
File > Settings > Editor > Code Style > Java > Tabs and Indents > Use tab character
Substitute weapon of choice for Java as required.
IntelliJ IDEA 15
Only for the current file
You have the following options:
Ctrl + Shift + A > write "tabs" > double click on "To Tabs" If you want to convert tabs to spaces, you can write "spaces", then choose "To Spaces". 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
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.
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}
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
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
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
My Intellij version is 13.4.1
Intellij IDEA->Perference->Code Style(Project Setting)
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.
For those who are having trouble indenting phpstorm here I have a tip and I hope they help ...
https://i.stack.imgur.com/iAuP0.png
If they are on the windows machine. If you are on mac and choose macos.
Success story sharing