Sublime Forum

Find Results double-click usability is questionable


I’ve been using Sublime Text 3 for years. I use Find in Files ... a lot. It’s bugged me for some time that double-clicking a line in the Find Results buffer doesn’t always load up the underlying file. Sometimes it does, sometimes it does not. It’s annoying as heck.

Painfully, I’ve just realized why this is. You can only double-click on the actual matching line (the one whose line number is followed by a colon). The other lines above and below this matching line are there for context but are not double-clickable.

I can’t imagine anyone preferring this behavior over the, likely, most obvious and expected behavior which is to open the file at the relevant line number whichever Find Results line you double-click.

Is there a config option to enable the more sensible behavior?



There’s not a config option for that, no; this mechanism is implemented using the same thing that allows you to double click on error messages in build results and have the file open at the given location. As such it’s triggered by specifically matching text, which in the case of Find in Files is the lines that represent matches (which have a : after their line number).

That said, you can get the behaviour you want with a plugin such as the following:

import sublime
import sublime_plugin

import bisect
import re

def handle_double_click(view, point):
    Handle a double click at the given point in the buffer; if the click is in
    a context line, trigger an open of the file on that line. For any other
    location, do nothing and let the default action occur.
    line = view.substr(view.line(point))
    match ="^\s+(\d)+ ", line)
    if match:
        file_list = view.find_by_selector('')
        line = int(

        file_idx = bisect.bisect(file_list, sublime.Region(point)) - 1
        filename = "{}:{}".format(view.substr(file_list[file_idx]), line)
        view.window().open_file(filename, sublime.ENCODED_POSITION)
        return ("noop")

    return None

class EnhancedFindInFilesListener(sublime_plugin.ViewEventListener):
    def is_applicable(cls, settings):
        return 'Find Results.hidden-tmLanguage' in settings.get('syntax')

    def on_text_command(self, command, args):
        if command == "drag_select" and args.get("by", None) == "words":
            event = args.get('event')
            point = self.view.window_to_text((event["x"], event["y"]))

            return handle_double_click(self.view, point)

This watches for double click actions in Find in Files results, and if the double click is on one of the context lines, the file will open on that line. See this video on how to use plugins if you’re not sure how to put the plugin in place.

There may also be packages available that do this on Package Control as well.



A simpler method would be to change the Find Results’ result_line_regex setting to not require the colon. The following works from the console, if you previously had the find results panel active, and can be transformed into a plugin that changes the setting when the view is created or activated.

>>> view.settings().get('result_line_regex')
'^ +([0-9]+):'
>>> view.settings().set('result_line_regex', r'^ +([0-9]+)')

Issue on the tracker to request this behavior to become the default: