Sublime Forum

Custom plugin similar to Find Results


I would like to develop a plugin that operates similarly to the “Find In Files…” menu item, but with the output from git grep. I want to use git grep instead fo the builtin regex search since GG supports --and and --not as query operators, along with expression grouping and group negation, allowing you to build very complex queries.

Specifically, I’d like to be able to click on matching lines and be taken directly to the correct file / line, as done in “Find Results”.

Where can I read up about how to build a plugin that does this in Sublime Text?



The first place I’d recommend is the API Documentation, which gives you a good idea of the sorts of things that are possible with the API. I also have a video course that covers the topic in general which might also be of some assistance, though we’re only at week 13 or so.

For your particular purposes, examining the exec command and how it works should give you some insight. The source for it is in Default/, which you can view by using View Package File from the command palette.

It shows executing an external program and capturing the output, creating an output panel and adding data to it. An output panel is just a view (as is a file tab), so sending the output to a tab is a fairly trivial enhancement to that.

The navigation that’s found in the Find in Files results uses the same file_regex and line_regex functionality as build systems do, so if the result of the command has an appropriate output you can gain that ability easily as well.

If not, then an event listener listening for the drag_select command with specific arguments can detect when someone is using the mouse to double click as well (an example of that can be found here)

1 Like