Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force SublimeText 2 to use 4 spaces tab? (it changes to spaces sometimes)

Often SublimeText 2 opens files and if it finds in some place some spaces instead of a tab.

I said to force everything to 4 tabs. Not to convert manually every file I open to tabs (like in How to replace four spaces with a tab in Sublime Text 2?)

Sometimes I have a document with tab indentation of 4 spaces and when I press tab it writes 4 spaces!

"detect_indentation": false,
"translate_tabs_to_spaces": false

(doing tab_completion=true it helps)

like image 675
Totty.js Avatar asked Mar 11 '13 22:03

Totty.js


People also ask

How do I change tabs to 4 spaces in Sublime Text?

To configure the tab width in Sublime Text 3, click on “View” in the top bar, then click on “Indentation” in the drop-down list. Next, in the second level of the drop-down list select the width you want a tab to take up. Sublime Text 3 defaults to tabs being four spaces wide.

How do I indent automatically in Sublime Text?

That's quite simple in Sublime. Just Ctrl+Shift+P (or Command+Shift+P on MacOS) to open the tools pallet, type reindent , and pick Indentation: Reindent Lines . It should reindent all the file you are in, just remember to save before running the command, or it may not appear.

How do I fix Sublime indentations?

by pressing ctrl+f12, it will reindent your file to a tab size of 4. if you want a different tab size, you just change the "value" number.

How do I change the spacing in Sublime Text?

Changing default indentation settings The following File Type Preferences determine the indentation settings: translateTabsToSpaces: set to either 'true' or 'false'. If true, then when tab is pressed, an equivalent number of spaces will be inserted into the buffer instead. Defaults to false.


1 Answers

If you set detect_indentation to true then ST2 will scan what the file uses for indentation, and that (a tab or spaces) will be what is inserted when you hit the Tab key. If you look at the bottom of the ST2 window, on the right side just to the left of where it shows the language of the current document, it should say something like Tab Size: 4 or Spaces: 4. You can click on that to (un)set the Indent Using Spaces option, as well as setting the size at which the tab character is rendered.

like image 133
MattDMo Avatar answered Nov 15 '22 08:11

MattDMo