akalongman / sublimetext-codeformatter

Code Formatter plugin for ST2/ST3
MIT License
772 stars 130 forks source link

It always indents PHP with four spaces #266

Open haunted2 opened 8 years ago

haunted2 commented 8 years ago

Hello, i used the "indent_with_space": 2 option but it still uses 4 spaces. I also tried with "indent_with_space": true but i'ts still the same. tab_size is always set to 2. Any hint? Thanks.

thecotne commented 7 years ago

this probably is bug but as i remember if you use indent_with_space: false and have configured sublime to indent with 2 spaces i think it will replace tabs with 2 spaces

mayankgureja commented 7 years ago

@haunted2 In order to solve this, I had to disable PSR2 formatting and manually add all PSR2 transformations except PSR2IndentWithSpace.

"psr2": false, // Activate PSR2 style
"passes": ["PSR2KeywordsLowerCase", "PSR2LnAfterNamespace", "PSR2CurlyOpenNextLine", "PSR2ModifierVisibilityStaticOrder", "PSR2SingleEmptyLineAndStripClosingTag", "ReindentSwitchBlocks"],
"exclude": ["ReindentComments", "StripNewlineWithinClassBody"]
subins2000 commented 7 years ago

PSR-2 requires 4 spaces. You can't enable PSR-2 and use 2 spaces.

davis-simanis commented 4 years ago

1) Settings -> Insert Spaces switch off that setting. 2) Then you will see Editor: Insert Spaces, click that and switch this off as well. 3) Then click Editor: Detect Indentation and switch it off, if your file already contains tabs with 4, because it will auto-detect and switch back to 4 when opened for that file.