Sublime Text plugin API: how to get a list of files in a project?

I am writing a plugin for Sublime Text 2/3, which should open several files whose names contain a specific line.

How can I get a list of files in a project? I can not find the related API function in the docs. I can do it with Python os.walk, but it is a bit slower. Sublime's menu, on the other hand, is Ctrl+Pincredibly fast, but I don’t know how to access its contents from my plugin.

+4
source share
1 answer

In the Sublime Text 3 API fot, there is a function for getting files in a project, but there is a function project_data()that returns information about the project. for files you can do like this:

project_data = sublime.active_window().project_data()
project_folder = project_data['folders'][0]['path']
# and here os.walk(project_folder )
+3
source

Source: https://habr.com/ru/post/1527540/


All Articles