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

前端 未结 8 1653
自闭症患者
自闭症患者 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:07

    Stumbled upon similar problem. When trying to record macros, which involved „Save“ command, console threw at me „Unknown macros command save“ message. Worked my way around with elementary plugin.

    1) Tools → New Plugin

    import sublime, sublime_plugin
    
    class MyChainedActionsCommand():
        def run(self):
            self.view.run_command("reveal_in_side_bar")
            self.view.run_command("focus_side_bar")
    

    You need to use upper camel case notation for the class name. ST2 exposes this class for the command name with „Command“ suffix removed and the rest converted into the lowercase-underscore notation. I.e. in this example MyChainedActionsCommand could be run in sublime's console typing: view.run_command("my_chained_actions")

    2) Sublime Text 2 → Preferences → Key Bindings — User

    Bind it to shortcut:

    { "keys": ["alt+shift+l"], "command": "my_chained_actions" }

    Heed commas.

提交回复
热议问题