Sublime Forum

Get ST3 to Open Several Chosen Files?



Is it possible to get ST3 to open several chosen text files? Say, I am working on several projects and each time open the same sets of files for them. Does anyone know? Thanks.



ST does have a command open_file that allows you to open any file on disk, given it’s absolute path but it doesn’t work with multiple files. One solution would to be to write a wrapper command around open_file to have it open multiple files.

import os
import sublime
import sublime_plugin

class OpenMultipleFileCommand(sublime_plugin.WindowCommand):

    def run(self, files=None):
        if files is None or len(files) <= 0:
            sublime.status_message("No files to open !")
        for file in files:
            if not os.path.exists(file):
            self.window.run_command("open_file", { "file": file })

And a sample key binding for such the above command (open_multiple_file)

        "keys": ["ctrl+shift+u"],
        "command": "open_multiple_file",
        "args": {
            "files": [

This would open multiple files in the same window when you press the said binding provided you give it a list of valid absolute file paths.



Thank you! Where should these be saved?



The code needs to be saved as a python file (.py) (the name really doesn’t matter) in your User directory (Preferences -> Browse Packages from main menu to get to the User folder).

The key binding goes in your user key bindings file and all of those "absolute_path_to_file_n" would be replaced with the file paths of the files you want to open.

If you have done all of this correctly (including getting the file paths correct), if you press the binding (I gave an example of ctrl + shift + u, you can choose whatever binding you prefer), the list of files will open in the current window.

Of course, this is just one possible solution. Based on what you actually want, the final solution may be different.

1 Like


Thank you very much, Ultra Instinct! It is just what I needed. Several texts are opened when a key combination is pressed.