Reputation: 1576
I'm new to SublimeText (migrated from TextMate) and it's awesome. But I'm familiar with JetBrains IDE and I need functionality to quickly open a file/class in a project. SublimeText provides cool features, like open symbol anywhere, goto anything and so on, but I can't find anything to open just files in a project. When I'm working on a big project – goto anything and similar are not suit for me.
For example, I have a class named Data. When I'm trying to open that class with 'goto anything/symbol in project' – I got a lot of variables and methods in the list, because 'data' is pretty common word in programming.
So, I'm trying to achieve functionality to open only classes/files, without searching inside of them (like JetBrains Navigate -> Class). Is there any built-in functionality, or I need to write a custom plugin for my needs?
Upvotes: 0
Views: 1676
Reputation: 19744
I threw the following together so you have an idea of something you can do. It might work well enough for you, if not, perhaps you can build off of it. This will grab every file, so perhaps you will want to add some sort of ignore patterns. If I recall, JetBrains works like that. For one shortcut it searches everything, for the other, just classes (well indexed files is probably more accurate)
import sublime_plugin
import os
class FileNameBasedOpen(sublime_plugin.WindowCommand):
def run(self):
self.input_content = []
for folder in self.window.folders():
for root, dirs, files in os.walk(folder):
for f in files:
self.input_content.append([f, root])
self.window.show_quick_panel(self.input_content, self.on_select)
def on_select(self, index):
if index == -1:
return
else:
f = os.path.join(self.input_content[index][1], self.input_content[index][0])
self.window.open_file(f)
Upvotes: 1