-
tab_size
means how wide a \t
char visually is.
-
translate_tabs_to_spaces
is used to insert spaces when press tab
key.
If your existing files are using 2-space indentation, then spaces are always spaces and fixed-width.
https://github.com/FriendsOfPHP/PHP-CS-Fixer should be able to fix most PHP coding style. Since 4-space indentation is mandatory in PSR-2, there should be lots of formatters which can fix it.
But I am not interested in introducing how to use it here… so you probably read the doc or existing tutorial written by others.
Generally in ST, to convert 2-space indentation to 4-space indentation, you can do as the following from the indentation menu in ST’s status bar.
- change tab width to 2
- convert indentation to tabs
- change tab width to 4
- convert indentation to spaces
Or, if you have Chain of Command installed, you can set a keybinding to it. (macro should be able to do the same job, but I am not familiar with it)
// convert 2-space indentation to 4-space indentation
{
"keys": ["f10"],
"command": "chain",
"args": {
"commands": [
[ "set_setting", {"setting": "tab_size", "value": 2} ],
[ "unexpand_tabs", {"set_translate_tabs": true} ],
[ "set_setting", {"setting": "tab_size", "value": 4} ],
[ "expand_tabs", {"set_translate_tabs": true} ],
],
},
},