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

前端 未结 8 1651
自闭症患者
自闭症患者 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])
    
    0 讨论(0)
  • 2020-11-29 19:13

    I've tried to use the same command but I ended up with a bug that when the file's folder was already unfolded sublime moved my focus sidebar's top, where I can see the open files. To improve this behavior I've wrote a new plugin that ensures it'll behave as I want to, here it is https://github.com/miguelgraz/FocusFileOnSidebar

    0 讨论(0)
提交回复
热议问题