如何将选择填充到sublimeText3 ctrl + p overlay?

时间:2016-06-23 12:29:46

标签: sublimetext

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

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

我想选择一个文本(文件路径),然后按ctrl + p将其填充到弹出式面板。

经过修改(但没有工作):

$(document).ready(function(){
       $("#bookingadd").validate({
          submitHandler: function (form){  
             form.submit();
          }
       });
       $.each($('input[type=text]'),function(){
            $(this).rules( "add", "required");
       });
       $.each($('select'),function(){
             $(this).rules( "add", "selectsubservices"); // value is not 0
       });
});

1 个答案:

答案 0 :(得分:5)

占位符不能应用于每个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
        })

然后打开你的keymap并添加命令:

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