10

As per How can I use tabs for indentation in IntelliJ IDEA?, I have gone through and set each extension to "Use tab character" as seen below.

It doesn't work though - IntelliJ is still inserting spaces when I hit the tab button. Did I miss something? Where is intelliJ's [Please use tabs like I ef'ing told you to do] button?

(FYI, I'm using IntelliJ Ultimate 2016.2)

This looks promising... enter image description here

... but apparently it's all lies :(

enter image description here

Community
  • 1
  • 1
doub1ejack
  • 10,627
  • 20
  • 66
  • 125
  • 1
    just out of interest: why do you want to use tabs instead of spaces? I actually hate when people use tabs in shared code as the formatting is most of the time messed up on at least one machine or source-viewer. – Michael Ritter Jan 23 '17 at 18:39
  • 10
    @MichaelRitter it doesn't matter *why* he wants to do it, or that you hate when it is done. I hate spaced indentation. It is equally as messed up on at least one machine or source-viewer. But our preferences don't help answer the question. – Wing Mar 28 '17 at 18:38
  • 2
    @MichaelRitter Indent with tabs, align with spaces. It's the purpose of smart tab option – LoganMzz Oct 05 '17 at 10:23
  • I was having a similar issue and Smart Tabs were the problem. – Gru Sep 02 '18 at 18:21

3 Answers3

10

Go to SettingsEditorCode Style and deselect ‘Detect and use existing file indents for editing’.

grg
  • 5,023
  • 3
  • 34
  • 50
3

Maybe you have the option Settings->Editor->General->"Allow placement of caret inside tabs" checked.

Deselect it and try again.

3

If you open up the .editorconfig file, you will see something akin to the following

# editorconfig.org  
root = true  

[*]  
indent_style = spaces  
indent_size = 2  
end_of_line = lf  
charset = utf-8  
trim_trailing_whitespace = true  
insert_final_newline = true

I changed it to tab and 4, closed the project and reopened it.
I know this is an absurd step to have to take, and have an open bug report with them about it.

Wing
  • 299
  • 1
  • 8
  • Wow. Reopening the project did a thing! Without the reopening, it was reporting absurd contradictory exceptions – Oleksandr Danylchenko Nov 02 '21 at 09:06
  • i had several files with different settings for `indent_size` so i searched the project and changed it to the settings i wanted. now it works, no restart nor reopening was required. – honk31 Mar 03 '22 at 11:32
  • FYI, https://editorconfig.org/ says you can define multiple file types like so `[*.{js,py}]` however, our project had `[*.{js}]` with `indent_style = tab` and spaces were still being inserted. It turns out that syntax does not work for one file extension. Changing it to `[*.js]` fixed things so that tabs are now used. – James Aug 07 '23 at 16:38