如何将选区填充到sublimeText3 ctrl+p叠加?

How to fill the selection to sublimeText3 ctrl+p overlay?

\Sublime Text Build 3065 x64\Data\Packages\Default\Default (Windows).sublime-keymap:

{ "keys": ["ctrl+p"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },

我想select一个文本(文件路径)并按ctrl + p将其填充到弹出面板。

修改后(但不起作用):

{ "keys": ["ctrl+p"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true, "text": "${0:$SELECTION}"} }

占位符不能应用于每一个sublime命令,但必须被命令支持。然而,您可以轻松编写自己的插件来获得您的行为

打开 Tools >> Developer >> New Plugin...、粘贴并保存:

import sublime_plugin


class ShowGotoOverlayWithSelectionCommand(sublime_plugin.WindowCommand):
    def run(self):
        window = self.window
        view = window.active_view()
        text = view.substr(view.sel()[0])
        window.run_command("show_overlay", {
            "overlay": "goto",
            "show_files": True,
            "text": text
        })

然后打开您的键盘映射并添加命令:

{ "keys": ["ctrl+p"], "command": "show_goto_overlay_with_selection" },