Question

I have a SCSS file I am currently working on. The indentation is 4 spaces, but for some reason PHPStorm only moves the cursor 2 spaces every time I tab. Is there a way to change this? Strange thing is I have other files in the project (mostly JS) and they are tabbed 4 spaces.

Was it helpful?

Solution

  1. Settings/Preferences
  2. Editor | Code Style
  3. Now select your desired language (as it's configured on per language basis) and check the option on the "Tabs and Indents" tab.

enter image description here

If you are using the actual Tab symbol for intents then you will see the changes straight away. But if you use Space then you will need to invoke Code | Reformat Code (or similar Code | Reformat File...) to see the changes in the indents.


In case if you have changed the settings in Code Style but still see the old/different settings being applied: check if you have .editorconfig file(s) in your project and EditorConfig is enabled (by default).

The settings from such a file will overwrite your Code Style settings (it's expected as it's the nature of such files). In this case you will need to edit your .editorconfig file (or disable EditorConfig integration).


P.S. I prefer setting the basic settings (like indent size, indent symbol etc) in the .editorconfig file. It's portable, flexible, and allows setting up different settings for files that do not have dedicated Code Style settings in the IDE.

OTHER TIPS

After applying the settings, the tab will not apply right away. For this to work you have to Code -> Reformat Code

You can set the tab and indent for each language you code in. enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top