Sublime Forum

Sublime Text 3 uses tabs instead of spaces for indentation

#1

I’ve posted this also on SO without any answer yet, so sorry for the duplication but this is really bothering…

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, "detect_indentation": false, "tab_size": 4

But no matter what, if the files were saved with tabs indentation (instead of spaces) ST3 will use tabs instead of spaces.
Also, 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.

Why is ST3 ignoring my settings??

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

1 Like

#2

What does the indentation settings in the lower right of your window say? Spaces or Tabs?

And does this happen on brand new files?

0 Likes

#3

I have no idea why all the editor writers think that tabs which are basically invisible and are of varying variable size by personal preference are cool. When I used to work on and IBM PC running DOS 1 and I only had 2 360K floppy drives then a tab saved a bit of space sometimes. I personally like to indent with 2 spaces and I have been doing so for much more than 10 years. I did update User Settings in Preferences on Windows today and it seemed to work for me. I currently do not have that box up and running now, I still have to update my Linux system with this.

0 Likes

#4

{
“color_scheme”: “Packages/Color Scheme - Default/Cobalt.tmTheme”,
“font_size”: 9,
“ignored_packages”:

	"Vintage"
],
"tab_size": 2,
"translate_tabs_to_spaces": true,

}

Is what I now have in user settings and looking at View Indentation it seems that it now honours my wishes here.

0 Likes

#5

On the low right corner my settings say: “Indent Using Spaces” but if the file was saved with tab it will opened and showed with tabs.
Each time I have to manually launch the command “Indentation: Convert To Spaces”

0 Likes

#6

I think the order goes:

  • Sublime default

  • language default

  • user settings

  • user language-specific settings

  • file settings

So if your file is saved to use tabs (for example by another program), it overrides all of the others

0 Likes

#7

This is because ST reads and parses these settings, changes a value of it and then saves it, overwriting all previous contents. This results in
[list=]
*] Comments being removed
*] The top-level dictionary’s (mapping’s) settings are sorted alphabetically, maybe even all.
*] The indentation is changed to one tab.
[/list]

This is a very special situation and applies only to settings files that ST or rather plugins change via the API.

0 Likes

#8

At the bottom of Sublime, you’ll see something like this:

If it’s showing Tabs: 4 then click and change it to Spaces: 4.

I had the same issue as yours and changing this will help. Remember to keep "translate_tabs_to_spaces": true in your user settings.

3 Likes

#10

oh my god, i already search in google. but still not found. just this… oh my god… thans diophung :slight_smile:

0 Likes

#11

Can you CTRL + H to replace (… -> tab) done.!

0 Likes

#12

Thank you!

0 Likes

#13

THANK YOU,
for the ‘command pallet > convert’ tip.
I’ve been through the menus a dozen times looking for a way to convert documents, that no one else will work on, not carrying if there are no longer tabs.
I didn’t want to just convert all older ‘tabbed’ docs without regards to who or why they wrote them.
Awesome. I can now convert the docs I want.

I was using find/replace ^[tabchar]{1,4} blah, blah.
Would have thought it would be in the Edit menu.
thanks again,
Landis.

0 Likes

#14

The menu items that you see when you click on the status bar are also available in the main menu, under View > Indentation; similarly the menu for the current syntax and line endings (if you have the setting enabled that turns that on) are there as well,

0 Likes

#15

Thanks diophung

0 Likes