7

I am working on a project where tab size is supposed to be 4 and tabs should not be spaces. I updated my Preferences.sublime-settings file to include

"detect_indentation": "false",
"tab_size": 4,
"translate_tabs_to_spaces": false,

When I open a new file these settings are set to how I want and everything works. However, if I open an existing file (scss or html) that has indentations as 2 spaces, my Sublime settings are overwritten and indentations change to 2 spaces. If I click View > Indentation I see that Tab Size is set to 2 and Indent Using Spaces is enabled, even though my preferences should be the opposite of that.

If I manually change Indentation via View > Indentation to Tab Width: 4 and deselect Indent Using Spaces, this works until I save the file, at which point the settings revert to Tab Width 2 and Indent Using Spaces turned on.

How can I force Sublime Text to honor my indentation preferences and not be overwritten by another file. I would assume that Sublime is detecting the indentations on the page, but I've turned that setting off.

Here is my preferences file showing that things should be working:

preferences file

Here are the messed up settings for a scss file. All I did was open it:

incorrect indentation settings

I don't think any plugin is causing this, I disabled most of them and was still experiencing this issue. However, for reference, here is a list of all packages I have installed:

  • Alignment
  • BracketHighlighter
  • Capybara Snippets
  • ColorPicker
  • Dotfiles Syntax Highlighting
  • EditorConfig
  • Emmet
  • ERB Snippets
  • Gem Browser
  • Gist
  • Git
  • GitGutter
  • Haml
  • jQuery
  • JSHint
  • Package Control
  • Pretty JSON
  • PyV8
  • RSpec
  • SCSS
  • SideBarEnahancements
  • SublimeLinter
  • Terminal
  • TrailingSpaces

Thanks in advance for any help.

2 Answers2

7

So I figured this out by completely uninstalling Sublime Text and all associated packages and settings, then reinstalling the app and one-by-one reinstalling my packages. It turns out that one of my packages, EditorConfig, was overwriting my Sublime Text style settings.

EditorConfig is actually a really cool plugin that allows a number of developers working on one project across multiple IDEs to have a consistent style by defining indentation type, size, charset, and other settings.

The answer to my problem was that in the particular project directory I was working some of the node modules I had downloaded had .editorconfig files that had indentation set as size 2 and spaces instead of tabs. I had to either uninstall the EditorConfig package from my Sublime Text or create a new .editorConfig file in the root directory of my project. This is the .editorConfig file I created that fixed my problem.

# top-most EditorConfig file
root = true

# 4 Tab Indentation
indent_style = tab
indent_size = 4
2

When a file is loaded, its contents are examined, and the "tab_size" and "translate_tabs_to_spaces" settings are set for that file. The status area will report when this happens. While this generally works well, you may want to disable it. You can do that with the "detect_indentation" setting.

This might be helpful: https://www.sublimetext.com/docs/2/indentation.html

BarzinM
  • 393
  • 3
  • 8
  • Thanks for the comment. I've actually set my user settings to have "detect_indentation" set to false. These are my indentation settings currently in my Preferences.sublime-settings file: `"detect_indentation": "false", "tab_size": 4, "translate_tabs_to_spaces": false,` Even with this I'm still getting the error. – jasonleibowitz Feb 13 '15 at 18:22
  • Change `"detect_indention": "false"` to `"detect_indention":false` – BarzinM Feb 13 '15 at 19:34
  • Barzin, my bad. The value of "detect_indentation" is already a boolean, not a string. It's false, not "false". – jasonleibowitz Feb 13 '15 at 19:40
  • In the first image you added. It seems that you need to remove `"`s of the last line. I don't know if that is going to help, but it worth trying. – BarzinM Feb 13 '15 at 19:49
  • So I made that change and changed the value of word_wrap to a boolean as well, but that didn't make a difference... – jasonleibowitz Feb 13 '15 at 20:57