【问题标题】:Syntax specific settings in sublime-project settings filesublime-project 设置文件中的语法特定设置
【发布时间】:2013-11-11 10:56:32
【问题描述】:

sublime-settings 文件在每个项目的基础上强制执行设置:

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

如何在此文件中使用特定于语法的设置,例如仅为 *.js 文件设置 2 的 tab_size

【问题讨论】:

  • 您是要为特定的项目.sublime-project 设置文件)设置这些设置,还是为任何.js 文件全局设置这些设置,无论其来源如何?
  • 对于此项目中的任何.js 文件。

标签: sublimetext2 sublimetext


【解决方案1】:

您可以结帐.editorconfig

基本上一个 .editorconfig 文件看起来像,

# 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

甚至还有一个不错的 Sublime Text 包,可以自动阅读和理解它们。只需将您的 .editorconfig 放入版本控制中,您就可以开始使用了。

【讨论】:

    【解决方案2】:

    您不能直接在您的用户 Preferences.sublime-settings 文件中设置语言专有设置。但是,在编辑给定类型的文件时,您可以使用菜单项Preferences -> Settings–More -> Syntax Specific – User 创建仅限于该类型的设置文件。

    这个新文件将出现在您的Packages/User 目录中,其名称与其语言相匹配,例如Markdown.sublime-settings 将是 Markdown 特定的设置文件。

    【讨论】:

    • 除非没有选择将此类文件复制到您的项目中。您不能设置此每个项目,它会出现。
    猜你喜欢
    • 2014-04-09
    • 2013-10-26
    • 1970-01-01
    • 2019-10-15
    • 1970-01-01
    • 2017-06-28
    • 2014-10-30
    • 2014-05-30
    相关资源
    最近更新 更多