简体   繁体   中英

Why the macro doesn't work?

Here is the macro, whcih, for some reason, doesn't work:

[
    { "command": "split_selection_into_lines" },
    { "command": "move_to", args: {"to": "hardeol"} },
    { "command": "move_to", args: {"to": "hardbol", "extend": true} },
]

I can do the same things via plugin, but I don't like to use it here:

import sublime_plugin
class SplitIntoLinesReverseCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.run_command("split_selection_into_lines")
        self.view.run_command("move_to", {"to": "hardeol"})
        self.view.run_command("move_to", {"to": "hardbol", "extend": True})

Why the macro doesn't work?

The macro doesn't work because the JSON that you're using to define it is invalid; the args key needs to be wrapped in double quotes, but it's not. As a result the Macro won't load and thus can't execute.

If your color scheme supports it, the invalid characters will be highlighted to indicate the problem for you.

A corrected version would be:

[
    { "command": "split_selection_into_lines" },
    { "command": "move_to", "args": {"to": "hardeol"} },
    { "command": "move_to", "args": {"to": "hardbol", "extend": true} },
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM