Search code examples
sublimetext3sublimetextsublime-text-plugin

sublime-hooks plugin - multiple commands on event hook


I use sublime-hooks plugin to run a sublime command on event hook. I usually use it to run only one command on event hook. I don't know how to run multiple commands on one event hook. I tried this, but it does not work.

CSS.sublime-settings

    {
    "on_pre_save_language": [
        {
            "command": [
                "autoprefixer",
                "css_comb"
            ]
        }
    ]
}

Solution

  • According to the plugin docs given in the provided link:

    Hooks are stored in the User, Project, or Language settings. Each of these expects a list of dictionaries. Each of those dictionaries satisfies the following:

    • command [...]
    • args [...]
    • scope [...]
    • views [...]

    So don't make an array of commands but add an object (with command/args) to the array for every command:

    {
        "on_pre_save_language": [
            {
                "command": "autoprefixer"
            },
            {
                "command": "css_comb"
            }
        ]
    }