5

The setting for the switch from space characters to tabs is Use tab character (Settings... -> Editor -> Code Style (-> {LANGUAGE}) -> [checkbox] Use tab character). But it works for me only in new files.

I've just created a new Zend Framework 2 skeleton based project. When I create a new file and edit it, tabs are used. But it doesn't work in the files, that already were there on project creating (e.g. /public/index.php, /module/Application/view/layout/layout.phtml, /public/css/style.css).

Is it a bug? How to make PhpStorm use tabs in all files?

5 Answers 5

7

Updated for PhpStorm 2016.3:

Preferences > Editor > Code Style

Uncheck "Indents Detection > Detect and use existing file indents for editing"

5

Go to Preferences => Code Style then scroll to the bottom and uncheck the Enable EditorConfig support option. This was overriding my 4 space tab setting.

3
  • Unchecking this option also works for WebStorm. I had a similar problem with my React .jsx templates not applying tabs.
    – ramoneguru
    Jul 13, 2016 at 18:13
  • Could you please add screenshots? I did not find " Enable EditorConfig support". Jun 7, 2017 at 18:15
  • @JulianMoreno These are the updated steps for the 2017.3.5 version. You need to now go to Preferences (mac) or File (win) and select Settings => Editor => Code Style and then uncheck Detect and use existing file indents for editing under the Indents Detection section. Mar 16, 2018 at 3:07
0

You can reformat those files: in the main menu select "Code -> Reformat Code". That will switch space characters to tabs, if the setting is set to "Use tab character". You can also do it on folders, it will reformat all files inside.

3
  • For me, "Code > Reformat Code" is creating a mixture of tabs and spaces. Every time I hit Enter, it indents with tabs (as expected), then adds two space characters. Very aggravating. I installed the EditorConfig plugin and created a .editorconfig file, but no difference. Jul 30, 2015 at 15:38
  • 1
    Resolved the issue by adding indent_size = 4 to my .editorconfig file. The bug seems to be triggered when tabs are used for indentation and an indent size isn't set. Jul 30, 2015 at 15:42
  • Yeah, but what if I don't want to reformat the whole file? Kind of makes a mess of Version Tracking when I just want my new work to use tabs!
    – Stephen R
    Dec 2, 2016 at 22:49
0

I had difficulty because my tab size was set larger than my indent size. When I set both equal (4 in my case), PhpStorm started behaving as expected.

0

For Windows and Linux

File | Settings | Editor | Code Style | | Tabs and Indents

For macOS

PhpStorm | Preferences | Editor | Code Style | | Tabs and Indents



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .