Sublime Forum

ST 2 is not identing Python files correctly

#1

I have ST 2, running on Debian 8.4 and for some reason that I ignore, indentation is set by default for any type of file to 3 spaces. This is occurs for Makefiles, C++, Python, etc…

I looked in under Preferences -> Settings - Default, I have:

// 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": false,

The the other configurations, Settings - User and Settings - Mode, are empty files.

Curiously, when I open the file Settings - Default I see the file type identified as JSON and indentation set to 4 spaces. Opening the file file Settings - User, I see the file type identified as JSON and indentation set to 1 tab.

This is driving me craze, because Python tends to be picky about indentation… How can I set the correct indentation for a file type ?

Thanks,

Nelson

0 Likes

#2

 
See this StackOverflow answer to better understand how sublime-settings files work:

##Change Default Settings in Sublime Text 3
 



 
Also, open:

Menu / Preferences / Settings - More / Syntax Specific - User

while you have a Python file open, and make sure there are no conflicting settings.

0 Likes

#3

Thanks, but the SO link doesn’t apply because I am using Sublime Text 2.

In the end, and after much experimentation, in the Default Settings:

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

I changed this option to false. And now things seem to work correctly.

0 Likes