Is there a way to open a file or folder in the left "Folders" bar in the system file explorer? Without this I have to open file explorer and navigate all the way to wherever this folder is in order to manipulate files, which is really inconvenient. This is a standard function for most tools with a navigation bar like this, I'd be very surprised if this was not possible in ST.
1 Answer
If you right click on a file in the sidebar, you have the option to "Open Containing Folder...", which will open the folder in your OS' default file explorer application.
However, there doesn't, by default, seem to be an option when you right click on a folder in the sidebar. However, as it is ST, it is easily customizable:
Create a file called Side Bar.sublime-menu in your User folder under the folder that is opened when you go to the Tools menu -> Browse Packages. Paste in the following contents and save it:
[ { "caption": "Explore Folder…", "command": "explore_folder", "args": {"dirs": []} }, ] Then, Tools -> Developer -> New Plugin... and replace the contents of the buffer with the following:
import sublime import sublime_plugin class ExploreFolderCommand(sublime_plugin.WindowCommand): def run(self, dirs): for dir_path in dirs: self.window.run_command('open_dir', { 'dir': dir_path }) def is_visible(self, dirs): return len(dirs) > 0 and save it in the same folder as explorefolder.py
Now you will see a new item in the context menu on folders:
4 Comments
dir is a reserved Python keyword so should ideally be changed to, for example, dir_path in the run() method's loop.folder instead ;)dir_path suggestion ;) more informative :)dir is my pet hate but id, str, and sum always cause minor annoyance too. :)
