Sublime Forum

Tab width bug with Sublime Text 2 on Mac

#1

Here is a screenshot: grab.by/eSMA
Both files are .html.erb and the syntax editing is HTML.

I have the following in my preferences (user preferences).
“margin”: 2,
“tab_size”: 2,

What confuses me is why this one file has the tabbing incorrect, while the other file is correct. If I quit and reopen sublime text 2 I have the same results. I have Zen Coding and Package Control installed if either of those could be affecting the display.

Any ideas why some files are using 4 spaces for indents and others are using 2?

0 Likes

#2

There is a “detect indentation” setting that may* be causing this. Try this setting in your User/Preferences.sublime-settings:

"detect_indentation": false,
  • I turned this setting off a long time ago (because it was driving me nuts), so perhaps I’ve forgotten what the issues it causes look like.
0 Likes

#3

I believe I am having the same issue. I have what I believe are the defaults on Mac OSX 10.7.4 with ST2 2.0.1 build 2217. Working in a python file.

Something like this:

def foo(bar):
pass

Place the cursor after the colon and hit enter. I get a 2 space indent. Hit tab. I get another 2 space indent. I tried changing tab size to 8. Still 2.

I tried changing detect_indentation to false. Still 2.

In short, no setting that I changed in the settings caused any difference in tabbing behavior. Sure seems like a bug to me. I have the same version on FC17 Linux sitting next to me and it has none of these issues with the same settings.

Thanks,
David

PS. The settings:

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

// Set to true to insert spaces when tab is pressed
"translate_tabs_to_spaces": true,

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

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

// Calculates indentation automatically when pressing enter
"auto_indent": true,

// Makes auto indent a little smarter, e.g., by indenting the next line
// after an if statement in C. Requires auto_indent to be enabled.
"smart_indent": true,

// Adds whitespace up to the first open bracket when indenting. Requires
// auto_indent to be enabled.
"indent_to_bracket": true,
0 Likes

#4

Has anyone found a solution for this? I Am also having this problem, super frustrating.

0 Likes

#5

I have been having this problem too, but I am on Windows.
One thing I suspect could be causing it - most of my files, I am the only one working in them. But the file in question, my coworker also edited and saved in his own environment (he uses a different code editor). It may be that his editor saved the file with different tab settings.
It may not be the case, but is the only thing I can think of that changed with this file compared to the rest. May be worth checking out if this is happening to you.

0 Likes