Is it possible to chain key binding commands in sublime text 2?

前端 未结 8 1636
自闭症患者
自闭症患者 2020-11-29 18:06

There are times in Sublime Text when I want to reveal the current file in the side bar and then navigate around the folder structure.

This can be achieved using the

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-29 19:10

    Building on Artem Ivanyk reply, here is a version of ChainedActions that works with arguments. It takes two arguments for actions and args. Both are lists and each command in the list gets executed with the corresponding arguments. This admittedly stupid example inserts two snippets: view.run_command("chained_actions", {"actions":["insert_snippet","insert_snippet"],"args":[{"contents": "($0)"},{"contents": "1($0)"}]})`

    import sublime
    import sublime_plugin
    
    class ChainedActionsCommand(sublime_plugin.TextCommand):
        def run(self, edit, actions, args):
            for i, action in enumerate(actions):
                self.view.run_command(action, args[i])
    

提交回复
热议问题