Sublime Forum

Indenting and tabs

#1

How do I get Sublime to use tabs instead of spaces? My default configuration looks like this:

// 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,

// If translate_tabs_to_spaces is true, use_tab_stops will make tab and
// backspace insert/delete up to the next tabstop
"use_tab_stops": true,

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

Whenever I type a tab character, instead, i get 4 spaces and nothing I do changes that. In fact, the only way I can seem to get tabs into my documents is to do a global search and replace for 4 spaces and replace them with \t.
This is very frustrating, especially considering my settings appear to be correct. It doesn’t even appear to behave consistently. The first tab is 4 spaces, but the second one is only 3.

In fact, this appears to be tied to the physical file (not the file type). If I create a new blank html file, save it, then try to insert tabs into it, they turn out as spaces. The same thing happens with javascript files. However, if I load a javascript file that actually uses tabs, delete everything out of it, save it as an empty html file, THEN the tab key behaves properly. I really have no clue why it behaves this way, no other text editor I have ever used does this.

Seriously, what do I have to do to get this working properly? I really only want to use tab characters. Never spaces. I don’t care what kind of document it is, when I press the tab key, I want it to insert a tab character.

0 Likes

#2

This looks like a issue on the Sublime Text core.
Try to set detect_indentation to false, and test it. It should work just doing translate_tabs_to_spaces as false.

0 Likes

#3

That appears to have fixed it! Thanks for the help!

0 Likes