Tabs and indents settings does not work
Hello,
I have a problem with tab and indents settings. In settings->codestyle->php->tabs&indents I have set tab character for indent. But when I push tab button it uses 4 spaces instead of tab. Also some files works properly with tabs and some files not.
Could you help me please?
请先登录再写评论。
Hi there,
1) If you have EditorConfig plugin installed .. and have .editorconfig files in your project (or maybe even folders above) .. such settings will be used from that file (if present there, of course) ignoring IDE settings (that's the actual idea/nature of this plugin)
2) Maybe you have "Detect and use existing file indents for editing" option enabled (Settings/Preferences | Editor | Code Style) .. and your file has an indent made with spaces somewhere on the top. Try it in brand new empty file -- does it work there?
The problem is still happening on RM-2017.1, but I found a solution for my situation.
I'm using it for Wordpress development, and as it mixes php with HTML content, I had to set both PHP code style and HTML code style to HTML.
It was also happening on files with no HTML.
Yes "Detect and use existing file indents for editing" was checked. Thank you very much. Have a nice day.
I'm having the same issue, clean install of PHPStorm on an existing project. No .editorconfig file or editorconfig plugin install. Settings screens attached as well as a screenshot of the spaces when I hit enter after the function opening brace.
@Andriy
I'm having the same issue as above but I don't have that box checked. I also don't have the EditorConfig plugin installed or enabled.
I believe all my settings are correct, but no matter what when I create a new line in any PHP file it adds it with spaces (when I want it to do so with tabs).
Your screenshots look absolutely fine.
Right now I do not know what else it might be.
I found this ticket: https://youtrack.jetbrains.com/issue/WI-32698 -- not sure how relevant it is for your case. Maybe other tickets.. but I personally not aware of them (I'm not associated with JB)
Right now I may suggest to try something among these lines:
P.S. Right now I can reproduce this:
BTW -- try with fresh Code Style schema (e.g. Default) and modify it. Will it be any better?
Perhaps there is a .editorconfig file in the project. The settings in .editorconfig override the Code Style settings in the preferences.
@Jonathan Bossenger
In your case it could be because of:
No better ideas right now.
In my case problem was in unchecked "Smart indent" checkbox in 'Editor > General > Smart Keys'. When it is checked autoindentation works correctly according to Code Style settings.
RubyMine 2007.1 shows error markings around all indentation tabs?
Ehud Pardo, I would suggest opening a new thread at RubyMine forum.
Issue resolved, it was due to RuboCop inspection, in RM-2017.1
I'm having the same problem, but with JSX in Rubymine. None of these suggestions seem to work for me. Any other ideas?
https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000433590-Codestyle-for-JSX
I also have the same issue. I don't have an .editorconfig file or the editorconfig plugin installed, I replaced all my spaces with tabs and I have "Detect and use existing file indents for editing" option disabled and still get spaces instead of tabs
@Javier - please attach screenshots that would illustrate the issue + screenshots of your code style settings
It's also doing this weird thing where it uses a tab for the first indent and then 4 spaces for the 2nd indent (screenshot attached)
@Andriy Bazanov thank you that was it, the file had some HTML in it and my HTML indents were spaces, switched that to tabs as well and its working, thank you.
Just another good reason to separate presentation from logic.
@Dmitry Tronin Sorry for the late response. I can also confirm that the problems with tabs and indents were caused by non-pure php files that contained HTML. I was developing some stuff in wordpress when this came up and it's more common to find there mixed php and html.
Right now it might be worth watching this ticket (to see what devs will say): https://youtrack.jetbrains.com/issue/WI-35370 or even https://youtrack.jetbrains.com/issue/WI-32401
At the same time -- see https://youtrack.jetbrains.com/issue/WI-17786 where it was asked to have it that way (as far as I understand).
From my end I may only say this: keep (big?) HTML chunks of code in separate files, templating system (like Twig or alike) or properly escaped -- do not mix them; or maybe just use the same indent settings.
Also make sure you arn't working in a file which has a specific setting set in Settings -> Editor -> Code Style.
For example; I was working in a .less file and thought the css/global code style settings were leading for this. I was breaking my head over why the file was using 2 spaces as indentation when I entered 4. Then I found that less has it's own code style under Settings -> Editor -> Code Style which uses 2 spaces in the settings..
In Editor>Code Style I changed my Scheme from "Project" to "Default" and it fixed the issue.