Pretty self explanatory, I just want to set up sublime to use 2 space indents for everything other than javascript
Asked
Active
Viewed 8,518 times
19
-
possible duplicate of [How do I force Sublime Text 2 to indent two spaces per tab?](http://stackoverflow.com/questions/9474090/how-do-i-force-sublime-text-2-to-indent-two-spaces-per-tab) – Mohamad Jan 03 '15 at 20:05
2 Answers
48
The accepted answer is unnecessarily complicated. Just open a Ruby file in Sublime Text 2, then:
This will create a new file called Ruby.sublime-settings in the Packages/User directory and open it for you. If the file already exists it will just be opened for editing. Now you just need to type in your preferred settings and save.

Hubro
- 56,214
- 69
- 228
- 381
-
1This doesn't address the fact that I wanted to use 4 spaces for javascript and 2 for everything else – Greg Guida Jun 11 '13 at 07:24
-
6@GregGuida: Sure it does. Set 2 spaces globally, then set 4 spaces for JavaScript using the syntax specific settings. – Hubro Jun 11 '13 at 08:18
27
Yes. You can create syntax specific settings files. Make a file named Javascript.sublime-settings
and save it in Packages/Javascript.
Then add:
{
"tab_size": 4,
"translate_tabs_to_spaces": true
}
For more information, check out the this page from the docs: http://readthedocs.org/docs/sublime-text-unofficial-documentation/en/latest/customization/settings.html

Liam Cain
- 13,283
- 5
- 39
- 29
-
2I think it should be saved in Packages/User/ instead, at least according to this: http://www.sublimetext.com/docs/2/indentation.html – dmonopoly Oct 01 '12 at 03:50
-
2If you're reading this comment, scroll down a little bit to check out the simpler approach in the answer below. Same code, but you don't need to worry about opening, finding, saving preferences. – Razi Shaban Jun 04 '15 at 20:36
-
Both paths of `Packages/Javascript/` and `Packages/User/` with filename `Javascript.sublime-settings` are worked. – Nick Tsai Jul 10 '17 at 07:53
-
I tried this and found a filename of `JavaScript.sublime-settings` (capital 'S') was the trick to making it work for me in `Packages/User/`. A less error-prone solution is posed below by @Hubro. – ssteele Jan 17 '18 at 17:25