如何使用预先填充的搜索字符串显示查找和替换面板?

Kei*_*all 6 sublimetext3 sublime-text-plugin

我知道可以使用show_panel命令(通过键绑定或插件)显示Sublime Text"查找和替换"面板,并控制启用/禁用哪些参数.

从Sublime Console面板运行的示例:

window.run_command('show_panel', { 'panel': 'replace', 'regex': True, 'case_sensitive': False, 'whole_word': False, 'in_selection': False, 'wrap': True, 'highlight': True, 'preserve_case': True })
Run Code Online (Sandbox Code Playgroud)

我想知道的是:有没有办法预先填充Find What:Replace With:价值观?

我找到了这个论坛帖子,但它没有回复,在这种情况下,非官方文档没有帮助.

我试过了:

  • 'find_what': 'string'
  • 'replace_with': 'string'
  • 'find_history': 'string'
  • 'replace_history': 'string'
  • 'find_history': ['string']
  • 'replace_history': ['string']
  • 'find': 'string'
  • 'replace': 'string'

编辑:我也尝试过:

  • characters
  • find_characters
  • look_for
  • search_for
  • find_regex
  • find_string
  • search_string
  • replacement
  • search_characters

以上都没有任何区别 - 面板总是预先填充了先前的搜索和替换值,而不是我传入的值.


我知道命令slurp_find_stringslurp_replace_string,它们将分别采用当前选择和更新Find What/ Replace With值,但我想要一种方法来做到这一点,而不必首先考虑选择 - 我只是想将值作为参数直接传递给该show_panel命令.

有谁知道可以使用哪些参数/参数来控制它?

Ger*_*che 3

运行命令后,您可以在窗口上运行插入命令show_panel

import sublime_plugin


class ShowPanelPrefilledCommand(sublime_plugin.WindowCommand):
    def run(self, interactive=True):
        self.window.run_command('show_panel', {
            'panel': 'find_in_files',
            'where': '<open folders>',
            'whole_word': False,
            'case_sensitive': False,
            'preserve_case': False,
            'regex': False,
            'use_buffer': False,
            'show_context': False,
        })

        self.window.run_command('insert', {'characters': 'hello'})

        if not interactive:
            self.window.run_command('find_all', {'close_panel': True})
Run Code Online (Sandbox Code Playgroud)