Sublime Forum

Tab sometimes tab, sometimes 4 spaces

#1

Hey everyone!

I’d like tabs to be tabs, not 4 spaces.
I do think I have set it like that in the settings.
Anyway, the issue is:

  • Sometimes, I get tabs.
  • Sometimes, tabs are being translated to 4 spaces.

I don’t know what causes this, but

  • Some of the files I create in Unity, others from within SublimeText or Textastic (iOS).
  • Within each file, one behaviour stays the same. I don’t get tabs translated to spaces when there are tabs within the same file and vice versa.
    Does anyone know what’s going on?
    Is this a bug? Are there meta files being interpreted?

Best wishes,
Shu

0 Likes

#2
	// Set to false to disable detection of tabs vs. spaces on load
	"detect_indentation": true,

In the absence of a third party package that might be messing with settings (e.g. EditorConfig), the general reason for what you’re experiencing is the setting above, shown with its default value.

When it’s turned on, as files as loaded Sublime will examine them to try and see if they’re indented with tabs or spaces (and of what size if spaces) and adjust the settings in that particular file to match, so that you can work with the content in the format that it’s in.

You can turn it off to stop that from happening so that it will always respect your preference.

Either way, the content of the file loaded from disk won’t be directly modified; so if you expect to work with tabs, but you open a file that’s using spaces, you’re going to end up with a file that has a mix of tabs and spaces in it if you don’t conform the contents.

0 Likes

#3

Thanks for the reply, OdatNurd!
This does look promising! I’ll have a look later!
Maybe I’ll just replace all 4 spaces with tabs then, rather than changing the setting, so that I see what’s there and not what Sublime works with.

0 Likes