Sublime Forum

Is there an API method for the "Find, Where, Replace" panel?

#1

Is there an API method for the

Find:    _______
Where:   _______
Replace: _______

functionality that is available from the GUI? If I have to I can manually use combinations of calls like for example I could first open all files specified in where, search each one, then show/do something with the results, but this seems tedious as the functionality is already supported in the GUI.

Is there a method available for this which can be used in a plugin?

0 Likes

#2

You can use the View.find() method to obtain matching regions and then use View.replace(). All of this should be done from inside a TextCommand.

https://www.sublimetext.com/docs/3/api_reference.html

0 Likes

#3

Thanks for the reply.

I know I can use the view.find() method to search within a file.

What I am curious about is more specifically the ‘where’ clause that is available through the gui. Is there a function which can accept the where clause as its arguments? Or does the where clause need to be created manually?

I would imagine that somewhere there is a method which underlies the GUI ‘where’ clause, but I haven’t seen it in the documentation.

Does it exist?

0 Likes

#4

No, I don’t think that functionality exists in the API.

0 Likes

#5

you can programmatically open the dialog and fill these fields, but I don’t remember any way to click “find” or “replace”

0 Likes

#6

Would you be able to fill those fields in the panel while the panel is hidden from view of the user so it seems more seamless?

0 Likes

#7

I don’t know what you mean, you can do this, via View - Show Console:

sublime.active_window().run_command("show_panel", {"panel": "find_in_files", "where":"smethig", "replace":"something2", "find":"lalal" })

0 Likes

#8

To clarify, what I mean is to be able to fill the panel programmatically, without the user ever seeing the panel.

For example it would be something like run_command('hide_panel', args{}), but it seems like this is not possible.

0 Likes

#9

You want to “click” the “find” or “replace” buttons? That looks like is not possible.

You can open it and fill it, and you can even close it. But not “run it” as I understand.

0 Likes