Sublime Forum

Fuzzy-search (& jump to) any LINE via quick-panel (plugin)


lol I initially wrote this for a non-programming related project, but it’s turned out so useful, I always reach for it. I find that if I need to navigate to some place, I can almost always remember/reconstruct what the line roughly is like, so this procedure actually comes quite natural to me.

This is the code, some chunk of which is lifted out of (seriously, if someone better versed with python and/or sublime plugin development should write a better version, preferably allowing searching all lines in all open files)

import sublime
import sublime_plugin

class NavigateToLineViaQuickPanel(sublime_plugin.WindowCommand):
    def run(self):
        v = self.window.active_view()

def osp(view):

    def highlight_entry(x):
        jojo = sublime.active_window().active_view().file_name()
        window = sublime.active_window()
        jojo + ":" + str(x+1),
        flags=sublime.TRANSIENT | sublime.ENCODED_POSITION | sublime.FORCE_GROUP)

    def select_entry(index, orig_view, orig_sel):
        if (index==-1):
            if orig_view:
            view.run_command("goto_line", {"line": index+1})

    orig_sel = None
    if view:
        orig_sel = [r for r in view.sel()]

    j = view.lines(sublime.Region(0, view.size()))
    # [[view.substr(y),str(ind)] for ind, y in enumerate(j)],
    [view.substr(i) for i in j],
    on_select=lambda x: select_entry(x, view, orig_sel),
    on_highlight=lambda x: highlight_entry(x),
    flags=sublime.KEEP_OPEN_ON_FOCUS_LOST | sublime.MONOSPACE_FONT)


Thanks for this plugin. I do sometimes just want to search something in the current file but I don’t actually want to move my cursor to them (I just want to see something). The only pity is that, the panel is so large that it makes most part of codes unable to be seen on my small screen :confused:

I wonder the following part won’t work in a buffer (unsaved file) since jojo will be None.

        jojo + ":" + str(x+1),
        flags=sublime.TRANSIENT | sublime.ENCODED_POSITION | sublime.FORCE_GROUP)

Because this command is always working in the same file, the following command will be enough and working for a buffer as well?

self.window.active_view().run_command("goto_line", {"line": idx + 1})

Eventually, I have this, which behaves just like ctrl + r.

1 Like


Just as a heads-up, ctrl-I opens the incremental find panel which leaves you with your initial selection when you press Esc to close it (as opposed to return).



Very cool plugin thank you !!!

Your search includes only the one open file.

  • Is it possible to do the same - by including a search for the entire project all folders?

  • And is it possible to make that the value of the search is not erased after the end of the search, but remains after the call again in the same position?


This is a ready hot key, it may be useful to someone
{ "keys": ["alt+4"], "command": "navigate_to_line_via_quick_panel" },



Repost because the link I post was outdated due to I use master rather than a specific commit hash in my previous post.