indent detection

i have phpstorm 10
when i open new file with tabs, it not convert it to spaces
i disable checkbox in settings -code style-indent detection but still not work
how can i set automatic replace tabs with spaces when open file?

0

Hi there,

There is no "automatic replace" from tabs to space or other way around. PhpStorm may only detect what indents are used in the file and if they do not match your current settings it may offer to make such replacements.

But you can always do such replacement manually: "Edt | Convert Indetnts | To Spaces/To Tabs"

0

But what mean checkbox "detect and use existing file indents for editing"?
When it checked, phpstorm will use current indents from file, but what about case when it not checked?

0

If it checked then IDE will use the same indents as in the file ignoring your actual settings. This means: if you are using Tabs in this file but in your settings you are using Spaces .. then IDE will use Tabs for this file.

If this option is disabled then IDE will always use your current settings.

In any case: no automatic indent conversion/replacement will be happening, especially on non-modified lines.

0

Hi,

this functionality doesn't seem to work for me in Phpstorm 2022.2.1

I have "Detection existing indents" ON under Editor>CodeStyle and in a file with "mostly" spaces, it still uses Tabs as I configured them as preferred tab method for PHP and HTML file types.

How does the IDE detect the tabbing of an existing file?

0

DrLightman

I suggest you share an example file + Export your Code Style as XML file and share it as well (not just copy-paste the content, but the actual file) -- use things like Google Drive/Dropbox/iCloud/OneDrive to share the file that will preserve the original symbols.

With that on hand it can then be tested locally.


From what I know, the detection happens on the first 10 or so lines and should use the first indent symbol.

P.S.

  • Autodetection may not work if you have .editorconfig files -- settings from there should overwrite it (they do for per file type settings)
  • Mix of PHP & HTML in one file may have other issues with indents (there are some nuances) -- but I'm not sure if detected indent will be affected in such a case (as I have autodetection disabled since it was introduced (years and years ago) -- was a bit buggy back then and I did not liked it)
0

请先登录再写评论。