ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Project Specific Syntax Settings

by reywood ST3

Allows syntax settings to be specified per project in Sublime Text

Details

Installs

  • Total 4K
  • Win 1K
  • OS X 2K
  • Linux 551
Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8
Windows 0 1 0 4 6 5 5 7 2 1 2 2 0 4 3 3 2 0 7 2 5 9 2 0 4 0 1 2 3 3 4 2 4 3 1 3 3 1 6 0 4 2 1 0 1 4
OS X 1 2 1 0 3 0 0 1 1 1 2 1 1 0 5 0 1 0 2 0 5 4 2 1 2 2 1 2 2 2 0 2 2 3 3 2 0 2 2 3 1 3 1 0 1 1
Linux 0 0 1 0 1 0 0 1 1 0 1 0 0 3 3 2 1 1 0 3 0 0 0 0 2 0 0 0 0 0 0 0 2 0 2 1 1 0 0 1 0 2 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Project Specific Syntax Settings

This package allows syntax settings to be specified per project.

In your .sublime-project file, you just need to add a syntax_override section, like so.

{
    "folders":
    [
        // Your project folders
    ],

    "syntax_override": {
        "\\.html$": ["Handlebars", "grammars", "Handlebars"],
        "\\.js$": ["Babel", "JavaScript (Babel)"]
    }
}

The syntax_override section can contain as many key/value pairs as you like.

The easiest way to construct these key/value pairs is to follow these steps:

  1. Open an existing file in your project.
  2. Set the syntax you would like to use for that file with the View > Syntax > ... menus or the command palette.
  3. Right click in the file editor area, and select the Project Specific Syntax > Copy syntax setting to clipboard menu item. This menu item is also available via the command palette.
  4. Open your project file for editing via the Project > Edit Project menu or the command palette.
  5. Paste the new key/value pair into the syntax_override section of your project file. Be sure to add any necessary commas to separate multiple key/value pairs so your project file is still valid JSON.

If you need more control, you can construct your own key/value pairs. The key should be a regular expression that will be matched against the name of the file. Note that the . in .html in the example above has to be escaped to \. since it will otherwise match any character. And since this is a JSON string, we need to escape the slash, so we end up with \\..

The value in the key/value pair should be an array containing two or more strings. All but the last string in this array are the names of the package directories containing the syntax file and the last is the name of the syntax. Root around in Sublime Text's directory structure to find files that end with .tmLanguage. The names of these files (minus the .tmLanguage extension) are what you would use for the last string. Typically, you will only have two strings, a directory name and the syntax file name (minus .tmLanguage file extension), but this is dependent on the package's directory structure.

More info about projects and the project file format can be found at the Sublime Text website and at the Sublime Text Unofficial Documentation website.