Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a shortcut for Sublime Text to find an open file (Eclipse Ctrl + E)?

Ctrl+P of Sublime Text lets me find a file from all project files.

However, there are too many duplicated names. I’m looking for a shortcut key like Ctrl+E in Eclipse, so that I just need to find the file in my opened file. That would save a lot of key striking. Probably called “sidebar filter”?

Does not matter if it’s 2 or 3.

like image 858
Bomin Avatar asked Oct 25 '25 01:10

Bomin


1 Answers

Sounds easy to implement just select Tools >> Developer >> New Plugin... and add the content:

import sublime_plugin
import os


def _show_name(name):
    return ([os.path.basename(name), name] if name
            else ["untitled", "untitled"])


class ShowBuffersCommand(sublime_plugin.WindowCommand):
    def run(self):
        window = self.window
        views = list(window.views())
        show_entries = [_show_name(v.file_name()) for v in views]

        def on_done(index):
            if index == -1:
                return
            window.focus_view(views[index])

        window.show_quick_panel(show_entries, on_done)

Afterwards save it into your Package/User folder and add this (or an other keybinding) to your keymap:

{
    "keys": ["ctrl+e"],
    "command": "show_buffers"
},

(Tested on ST3)

like image 68
r-stein Avatar answered Oct 27 '25 01:10

r-stein



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!