Sublime Forum

Sublime using 2 space tabs for some files, even though it started as 4-space tabs

#1

I’m having an annoying problem.

I like to use tabs for indenting, with an equivalent space of 4 spaces per tab. But on some files I regularly use, every time I open the file in Sublime it converts all the tabs to 2 spaces each.

What’s the problem? How do I fix it? This is very annoying.

Thanks

0 Likes

#2

Provide a reproduce-able sample file would be helpful.

Another possibility is that you are using plugin like EditorConfig, which can control indentation. If you can reproduce the issue in safe mode, then it’s a core issue.

0 Likes

#3

Sublime Text detects tab size when loading a file using the first couple of lines. So resulting tab width depends on content.

This feature can be disabled by setting "detect_indentation": false.

0 Likes

#4

Thank you deathaxe, jfcherng.

If the file uses tabs, why would detect indentation change the file to using 2-space indentation??

0 Likes

#5

If ST is automatically converting the indentation then that’s being done by a plugin, ST doesn’t do that by default. As for why it may auto detect 2 space indentation in a file with tabs that’s usually due to the file also containing space-based indentation.

0 Likes

#6

Thanks. That’s strange, I’m pretty sure it just has tabs. I’m not using any plugins to my knowledge

0 Likes

#7

so, mind providing a sample file or try the safe mode? https://www.sublimetext.com/docs/safe_mode.html

1 Like

#8

Setting "draw_white_space": ["leading_mixed"] would visualize mixed indentation styles and could therefore help avoiding them.

2 Likes