sublimetext2 - SumblimeText2 Vintage command repeat -
how can bind command repeats?
for example: need bind command move cursor down 10 lines. 1 line it's this:
{ "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"}] }
write plugin:
import sublime, sublime_plugin class commandwithrepeats(sublime_plugin.textcommand): def run(self, edit, repeats, **args): x in xrange(repeats): self.view.run_command(args['command'], args['args']) and can add command in key bindings repeats:
"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 } } wrap command in command_with_repeats() , executes times (repeats arguement)
Comments
Post a Comment