Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text 3 always use tabs instead of spaces for indentation

I'd like to always use spaces instead of tabs for indentation in ST3.
I put these in my settings:

"translate_tabs_to_spaces": true,
"convert_tabspaces_on_save": true, // for a plugin
"detect_indentation": false,
"tab_size": 4

The setting convert_tabspaces_on_save is for forcing the conversion tabs-> spaces at least on file save with the plugin ExpandTabsOnSave

But no matter what, ST3 keeps indenting new opened files using tabs instead of spaces.

Could it be a bug or am I using a wrong setting?

HINT: anytime I modify the file Preferences.sublime-settings indirectly, for example by using the command Package Control: Disable Package it is saved with tabs instead of spaces

like image 221
Leonardo Avatar asked Jan 28 '15 10:01

Leonardo


2 Answers

According to the documentation, these settings should do the trick (they do work for me):

{
    // Integer. The number of spaces a tab is considered equal to
    "tab_size": 4,

    // Boolean, if true, spaces will be inserted up to the next tab stop when tab is pressed, rather than inserting a tab character
    "translate_tabs_to_spaces": true,

    // Boolean, if true (the default), tab_size and translate_tabs_to_spaces will be calculated automatically when loading a file
    "detect_indentation": true,

    // Boolean, If translate_tabs_to_spaces is true, use_tab_stops will make tab and backspace insert/delete up to the next tab stop
    "use_tab_stops": true
}

If this does not work, try disabling all plugins, restart and look if the problem persists. If not, it's one of the plugins (or several conflicting ones). You can find out by enabling them one at a time and looking for the issue to reappear.

like image 142
herrbischoff Avatar answered Nov 08 '22 11:11

herrbischoff


Try this: View -> Indentation -> Indent Using Spaces

like image 20
i.webdesigner Avatar answered Nov 08 '22 12:11

i.webdesigner