I'm editing files using Sublime 3.2.2 on my iMac.
I have already set tab-size to 2:
It works for some files but doesn't for some files - remaining 4-sized tabs. I can't even find a clue about which is right and which is not.
Are there any other places I need to check except the settings?
There are two things to consider here. First, this setting (shown here with the default value):
// Set to false to disable detection of tabs vs. spaces on load
"detect_indentation": true,
When this setting is turned on, when a file opens it's examined to try and detect how it;s indented. This will override the tab_size
in that particular file with whatever the detected tab size is, and can also override translate_taba_to_spaces
as well if the file appears to be indented a particular way.
The setting defaults this way so that you can use your settings to determine how you want to create new files while still allowing you to work with existing files in a sane way; setting it to false
turns off this detection.
The second thing to note is that preferences can be set on a per-file-type manner, which also overrides the settings in your user preferences for files of that type.
As an example, YAML
files have these settings applied (this is from YAML/YAML.sublime-settings
):
{
// YAML mandates that tabs aren't used for indentation
"translate_tabs_to_spaces": true,
// In practice, editing YAML files with anything other than two space
// indentation is tedious, due to the "- " list prefix
"tab_size": 2,
}
So, in a YAML file, regardless of your settings, the tab size defaults to 2 and using spaces over tabs is enforced.
As such, the takeaway here is that if changing the detection setting above doesn't work, check to see if the setting only seems to be "not working" in a particular type of file, and if so you can use Preferences > Settings - Syntax Specific
while you have a file of that type open to enforce your settings there.