Sublime Forum

Find in files from sublime API

#1

Hi.

I am writing a plugin for finding all function references in a project. Therefore i need to use the command “find in files”, but unfortunately i can’t find any example how to use “find in files” via sublime.run_command().
Is it even possible to do it this way?

0 Likes

#2

I believe the following should help, just change the panel argument to find_in_files to show the panel with the correct options:


then to execute the replacement, use the replace_all command

but if you want to set the text/expression being searched for, you’re out of luck unless it’s the selected text, whereby you can use the slurp commands…

0 Likes

#3

I think that aren’t good news…
I don’t want to show the find panel and don’t want to replace something.
Just do an regex search for the selected word on a specific folder and show the results in a result buffer.

0 Likes

#4

oops, I meant to execute the find, use the find_all command, sorry
I believe the user might not even see the panel, you just initialize it and execute the find_all command (which closes the panel) and it will show the results in a buffer

0 Likes

#5

Aah good. I will try that, thanks!

0 Likes

#6

How can i change the searched path in the find_in_files panel?

0 Likes

#7

if you open the ST console (View menu -> Show Console) and type sublime.log_commands(True) Enter and then right click on a folder in the sidebar and “Find in Folder”, you’ll see the following in the console:

command: find_in_folder {"dirs": ["the folder path here"]}

so you can just execute that command to set the location

0 Likes

#8

You’re my hero!

0 Likes