How to customise file type to syntax associations in Sublime Text?

I'd like Sublime 2 editor to treat *.sbt files (to highlight syntax) as Scala language, same as *.scala, but I can't find where to set this up. Do you happen to know?


In Sublime Text (confirmed in both v2.x and v3.x) there is a menu command:

View -> Syntax -> Open all with current extension as ...


I've found the answer (by further examining the Sublime 2 config files structure):

I was to open

~/.config/sublime-text-2/Packages/Scala/Scala.tmLanguage

And edit it to add sbt (the extension of files I want to be opened as Scala code files) to the array after the fileTypes key:

<dict>
  <key>bundleUUID</key>
  <string>452017E8-0065-49EF-AB9D-7849B27D9367</string>
  <key>fileTypes</key>
  <array>
    <string>scala</string>
    <string>sbt</string>
  <array>
  ...

PS: May there be a better way, something like a right place to put my customizations (insted of modifying packages themselves), I'd still like to know.


I put my customized changes in the User package:

*nix: ~/.config/sublime-text-2/Packages/User/Scala.tmLanguage
*Windows: %APPDATA%Sublime Text 2PackagesUserScala.tmLanguage

Which also means it's in JSON format:

{
  "extensions":
  [
    "sbt"
  ]
}

This is the same place the

View -> Syntax -> Open all with current extension as ...

menu item adds it (creating the file if it doesn't exist).

链接地址: http://www.djcxy.com/p/47102.html

上一篇: 通过unix管道过滤器输出多彩的控制台

下一篇: 如何在Sublime Text中将文件类型自定义为语法关联?