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

ぃ、小莉子 提交于 2019-12-30 11:06:29

问题


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.


回答1:


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)




回答2:


  • Option One, Go to the "View" menu and choose "Side Bar", then "Show Open Files"
  • Option Two, There is a small plugin here https://github.com/rrg/ListOpenFiles



回答3:


There is in Sublime Text a useful function called Goto Anything. You can access this by pressing Ctrl + P in Windows, and then you can search through any file located in a current project (to open a project, enable the sidebar, and drag and drop a folder from the explorer to the sidebar).



来源:https://stackoverflow.com/questions/38561302/is-there-a-shortcut-for-sublime-text-to-find-an-open-file-eclipse-ctrl-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!