问题
At the moment, I am trying out sublime text. Most of it is fine, but there is one big feature that I can't figure out how to implement in sublime text. In vim, have have space bound to repeat the last macro that I performed. However, I can't find a good way to implement it in sublime text.
In an effort to learn more, I looked at the macro key bindings in the vintage package:
{ "keys": ["q"], "command": "vi_end_record_macro",
"context": [{"key": "setting.command_mode"}, {"key": "is_recording_macro"}]
},
{ "keys": ["@", "<character>"], "command": "vi_replay_macro",
"context": [{"key": "setting.command_mode"}]
},
And (what I think) is the relevant class in the actual plugin:
class ViReplayMacro(sublime_plugin.TextCommand):
def run(self, edit, character):
What I am unable to figure out is how to remember what the last command was, and failing that just have space call the vi macro recorded on 'q'. This means I need to bind vi_replay_macro(q) to space, but I don't understand how the key binding passes which character to replay to the command.
EDIT: I created a plugin that does it.
回答1:
You would probably have to write your own plugin to run the last macro run. You can try using the command_history
method, then search backwards till you find a vi_replay_macro
or run_macro
command. I'm just making a guess though based on what I know about ST, so there could be other ways to go about it.
来源:https://stackoverflow.com/questions/16327580/creating-a-repeat-last-macro-keybinding-in-sublime-text-vintage-mode