How to run command on save in Sublime Text 3?

隐身守侯 提交于 2019-12-03 17:01:06

问题


Sublime Text offers built-in commands, such as paste, new_window, toggle_comment etc. In addition, some plugins offer their own commands that can be used for key binding.

Can I force any of these commands to be ran on file save? The reason I need is because I'd like to run CSScomb on file save instead of / in addition to having key binding for it. The command name is css_comb.


回答1:


Sublime-hooks package allows you to run packages based on event (on new, on save, etc.), so you can use it to achieve your goal. Just add this code to CSS syntax settings:

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

If you are familiar with plugins maybe you can make a plugin that extends EventListener and override on_post_save or on_pre_save methods.



来源:https://stackoverflow.com/questions/31494950/how-to-run-command-on-save-in-sublime-text-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!