How to run a command to save in Sublime Text 3?

Sublime Text offers a built-in commands, such as paste, new_window, toggle_comment, etc. In addition, some plugins offer their own commands that can be used to bind keys.

Can I get any of these commands to run when the file is saved? The reason I need is because I would like to run CSScomb to save the file instead of / in addition to binding the key to it. The name of the team css_comb.

+6
source share
1 answer

The Sublime-hooks package allows you to run packages depending on the event (in a new way, when saving, etc.), so you can use it to achieve your goal. Just add this code to your CSS syntax settings:

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

If you are familiar with plugins, perhaps you can create a plugin that extends EventListener and overrides on_post_saveor on_pre_save.

+7
source

Source: https://habr.com/ru/post/1598535/


All Articles