TAGS :Viewed: 7 - Published at: a few seconds ago

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

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

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

I want to select a text ( file path ) and press ctrl + p to fill it to the popup panel.

After Modified( but doesn't work):

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

Answer 1

The placeholders can not applied to every sublime command, but must be supported by the command. However you can easily write your own plugin to get your behavior

Open Tools >> Developer >> New Plugin..., paste, and save:

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

Afterwards open your keymap and add the command:

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