Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax specific settings in sublime-project settings file

A sublime-settings file enforces settings on a per-project basis:

{
    "folders": [ ... ]
    "settings":
    {
        "tab_size": 4
    }
}

How is it possible to use syntax specific settings in this file, for example to set a tab_size of 2 only for *.js files?

like image 998
Yuval Adam Avatar asked Nov 11 '13 10:11

Yuval Adam


People also ask

How do I change the syntax in Sublime Text?

sublime-syntax file, then just download it and copy it to ~/. config/sublime-text-3/Packages/User . It will then be available in the syntax menu at the very bottom right of the Sublime window, either on its own (it will say "SystemVerilog") or under the User submenu, depending on your setup.

What is sublime-project file?

Projects in Sublime Text are made up of two files: the . sublime-project file, which contains the project definition, and the . sublime-workspace file, which contains user specific data, such as the open files and the modifications to each.


1 Answers

You could checkout .editorconfig.

Basically an .editorconfig file would look like,

# editorconfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,py}]
charset = utf-8

# 4 space indentation
[*.py]
indent_style = space
indent_size = 4

# Tab indentation (no size specified)
[Makefile]
indent_style = tab

# Indentation override for all JS under lib directory
[lib/**.js]
indent_style = space
indent_size = 2

# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2

There's even a nice Sublime Text package that automatically reads and understands them. Just throw your .editorconfig in version control and you're ready to go.

like image 106
garetmckinley Avatar answered Sep 28 '22 11:09

garetmckinley