PHPstorm reformat

Hi,

 

I've specified to not use a tab character in my php settings, but when I reformat code, leading spaces become tabs again. Is there another setting for this?

4 comments
Comment actions Permalink

Could you please show a code snippet with an example?

0
Comment actions Permalink

Hi there,

>Is there another setting for this?

Check .editorconfig file(s) that you may have in this project (project root is the most common place) or even upper folders/user home. Settings from there will override IDE settings (the nature of such files).

0
Comment actions Permalink

I can't seem to reproduce it again this morning...

 

Basically, I did a replace of \t regex with two spaces. PHP Code style had tab character switched off. Ctrl-Alt-L would then replace two spaces with \t

 

 

0
Comment actions Permalink

>Basically, I did a replace of \t regex with two spaces. 

FYI: there is dedicated action for such leading whitespace conversion: select desired lines (e.g. whole file) and invoke "Edit | Convert Indents | To xxx") -- it will do that without do ing the actual code reformat. Will also not touch any tab symbols between elements (e.g. alignment or text block etc") that simple RegEx replace will do.

>Ctrl-Alt-L would then replace two spaces with \t

You may have "Settings/Preferences | Editor | Code Style | Detect and use existing file indents for editing" option enabled. In such case editor may indeed remember the original indent while file is still opened.

0

Please sign in to leave a comment.