4

I am working with some .scss.liquid files and they always open as HTML Liquid, no matter how many times I set the syntax.

Update:

I tried open all with current extension as option, but unfortunately this affects files that are .js.liquid and .html.liquid as well.

3
  • Especially this answer where the comment notes that it works with double extensions Mar 26, 2018 at 17:42
  • Thanks @DarrickHerwehe, the answer is indeed buried as a comment to one of the non-accepted answers on that question's page. My suggestion is to create a more accessible answer here as my Google fu is good and I didn't find that before. Clearly having a more specific question and answer here would be beneficial to the community. Please feel free to provide the canonical answer to the double filetype extension issue here.
    – Abram
    Mar 26, 2018 at 17:45

2 Answers 2

5

Sublime Text allows you to apply settings on a per-language basis (actually, per syntax). One of the available settings allows you to map file extensions to the given syntax.

Assuming you're using a syntax named SCSS, Create an SCSS settings file in your User settings: /path/to/packages/User/SCSS.sublime-settings, then add the file extension setting:

{
    "extensions":
    [
        "scss.liquid"
    ]
}

As you can see, it's a json file, and extensions is a list, so you can add as many file extensions as you need. Do not add the leading dot.

Caveat about the file name

The file name for the settings file must match the actual syntax name, including case. In this case it has to be SCSS.sublime-settings. Other examples include:

NAnt Build File.sublime-settings
Ruby on Rails.sublime-settings
Rd (R Documentation).sublime-settings
Java Server Page (JSP).sublime-settings
1
0

I found a relatively straightforward solution to this problem.

  1. Install ApplySyntax
  2. Create the following rules in ApplySyntax.sublime-settings -- User:

    "syntaxes": [
        {
            "syntax": "SCSS",
            "extensions": ["scss.liquid"]
        },
        {
            "syntax": "JavaScript/JavaScript",
            "extensions": ["js.liquid"]
        },
    ]
    

Update: I now see there is no need for an extra package. Please see accepted answer and my video (in the comments) for tips on how to make it work.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.