Sublimetext2 SumblimeText2复古命令重复
如何用重复绑定一些命令 例如:我需要绑定一个命令来将光标下移到10行。 一行是这样的:Sublimetext2 SumblimeText2复古命令重复,sublimetext2,Sublimetext2,如何用重复绑定一些命令 例如:我需要绑定一个命令来将光标下移到10行。 一行是这样的: { "keys": ["alt+j"], "command": "set_motion", "args": { "motion": "move", "motion_args": {"repeat": 1,"by": "lines", "forward": true, "extend": true }, "linewise": true }, "context": [{"key"
{ "keys": ["alt+j"], "command": "set_motion", "args": {
"motion": "move",
"motion_args": {"repeat": 1,"by": "lines", "forward": true, "extend": true },
"linewise": true },
"context": [{"key": "setting.command_mode"}]
}
编写一个插件:
import sublime, sublime_plugin
class CommandWithRepeats(sublime_plugin.TextCommand):
def run(self, edit, repeats, **args):
for x in xrange(repeats):
self.view.run_command(args['command'], args['args'])
然后我们可以在键绑定中添加任意命令,并重复执行:
"keys": ["alt+j"],
"command": "command_with_repeats",
"context": [{"key": "setting.command_mode"}],
"args": {
"repeats": 10,
"command": "set_motion",
"args": {
"motion": "move",
"motion_args": {
"by": "lines",
"forward": true,
"extend": true
},
"linewise": true
}
}
用_repeats()将command_中的任何命令包装起来,它会执行多次(repeats
arguement)