Sublime Forum

Switching projects changes tab spaces in python projects

#1

I have three projects I switch between on a regular basis.

Didn’t notice at first and it seem on a switch the tab spaces can change from 4 to 2.

I tried the following

  • edit project
    added this to the sublime-project file

“tab_size”: 4

but makes no difference.

0 Likes

#2

What’s your detect_indentation set to?

0 Likes

#3

when i switch projects, the status bar says “Detect indentation: Setting indentation to 2 spaces”

Bottom right says

Spaces:2 Python

How exactly does it detect what spaces are to be used ? Is it based on file type of the first files that open ? (in this case would be .py)

0 Likes

#4

Heuristic algorithm based on first x lines of the file.
It’s detected for each file you open, so could be different for each file.
Works pretty good but sometimes get fooled if file begin with a lot of line with more than one indent (like 1 line with 1 indent followed by 50 lines with 2 indent).

If you’re sure all your files have the same indent settings, you can disabled it with:

"detect_indentation": false
0 Likes

#5

thank you for the reply. The files do look fine. Its a django project.

Pretty new to sublime, where does the detect_indentation go ?

I did project-> edit and added it to the project.sublime-project file but it doesn’t appear to do anything.

{
	"folders":
	
		{
			"path": "/home/mark/workspace/djangoProject",
			"file_exclude_patterns": ".*"],
		    "detect_indentation": false
		}
	]
}

[quote=“bizoo”]Heuristic algorithm based on first x lines of the file.
It’s detected for each file you open, so could be different for each file.
Works pretty good but sometimes get fooled if file begin with a lot of line with more than one indent (like 1 line with 1 indent followed by 50 lines with 2 indent).

If you’re sure all your files have the same indent settings, you can disabled it with:

"detect_indentation": false
0 Likes

#6

You can add it to your project, but don’t put it under the “Folders” setting… put it next to it.

{ "detect_indentation":false, ... }

0 Likes

#7

[quote=“adzenith”]You can add it to your project, but don’t put it under the “Folders” setting… put it next to it.

{ "detect_indentation":false, ... }[/quote]

I put it in a “settings” section, but maybe it’s not mandatory:

[code]{
“folders”:

  {
     "path": "/home/mark/workspace/djangoProject",
     "file_exclude_patterns": ".*"]
  }

],
“settings”:
{
“detect_indentation”: false
}
}[/code]

0 Likes

#8

I think you might have to do that, actually.

0 Likes

#9

Success !

thank you.

[quote=“bizoo”]

[quote=“adzenith”]You can add it to your project, but don’t put it under the “Folders” setting… put it next to it.

{ "detect_indentation":false, ... }[/quote]

I put it in a “settings” section, but maybe it’s not mandatory:

[code]{
“folders”:

  {
     "path": "/home/mark/workspace/djangoProject",
     "file_exclude_patterns": ".*"]
  }

],
“settings”:
{
“detect_indentation”: false
}
}[/code][/quote]

0 Likes