Sublime Forum

Tab stops ignoring preference settings

#1

I’ve seen this reported and discussed several times on stackoverflow, yet none of the solutions provided there are working for me. I have the following settings in both my user and C++ syntax-specific preferences:
“always_show_minimap_viewport”: true,
“caret_extra_bottom”: 5,
“caret_extra_top”: 5,
“auto_complete_commit_on_tab”: true,
“auto_find_in_selection”: true,
“color_scheme”: “Packages/Color Scheme - Default/Mac Classic.tmTheme”,
“ensure_newline_at_eof_on_save”: true,
“highlight_line”: true,
“highlight_modified_tabs”: true,
“ignored_packages”:
[
“Vintage”
],
“indent_guide_options”:
[
“draw_active”
],
“indent_to_bracket”: true,
“open_files_in_new_window”: false,
“translate_tabs_to_spaces”: true,
“trim_trailing_white_space_on_save”: true,
“detect_indentation”: false,
“tab_size”: 4

However, whenever I open a C++ file, the “Spaces” field in the lower right corner shows “2” and the indent falls to 2 spaces. I can reset it to “4”, but I don’t understand why my preferences are being ignored. Any advice?

This is Sublime Text 3, build 3176
Ralph

0 Likes

#2

Normally the first thing I would suggest is to try turning off detect_indentation because that tends to cause issues, but you already have it turned off.

Does this issue apply to files of all types or only C++ files? Your question makes it sound like it happens when you open C++ files, in which case something to try would be to select Preferences > Settings - Syntax Specific from the menu while you have the focus on a C++ file to see if there is a setting in the C++ specific settings that’s overriding the defaults.

0 Likes

#3

I’m not sure but may have tracked this down. The problem was manifested when I opened .h files, which ST3 was identifying as C++. I noticed that I wasn’t seeing the problem when I opened a .c file, and so I took a closer look at the C-specific settings. They were mostly the same as what I had in C++, but just a couple of differences - here are the C-syntax settings:

"auto_complete_commit_on_tab": true,
"auto_find_in_selection": true,
"color_scheme": "Packages/Color Scheme - Default/Mac Classic.tmTheme",
"detect_indentation": false,
"ensure_newline_at_eof_on_save": true,
"extensions":
[
	"h"
],
"highlight_line": true,
"indent_guide_options":
[
	"draw_active"
],
"indent_to_bracket": true,
"open_files_in_new_window": false,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true

For some reason, these worked while the others didn’t. Weird, but by simply changing the default syntax for .h files to C, my problem at least is resolved.

0 Likes

#4

Something to note is that the settings in your general preferences (i.e. Preferences.sublime-settings) are the “base” or “global” settings, and then the syntax specific settings, if any, are applied on top of them as appropriate.

So all else being equal, the syntax specific settings only need to contain the settings that you want to be different from your global settings.

For example, you don’t need to specify color_scheme in your syntax specific settings unless you want the color scheme for files of that type to be different than what is set in the other preferences, but yours examples above show them both being set to the same thing.

0 Likes