2

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 1

13

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.

sidebar open containing folder

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:

new explore folder sidebar context menu item

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks Keith. I never knew I was missing this until now. One ever-so-trivial, non-breaking, quibble. dir is a reserved Python keyword so should ideally be changed to, for example, dir_path in the run() method's loop.
nice spot, I didn't think of that :) I've changed it to folder instead ;)
I changed my mind, I prefer your dir_path suggestion ;) more informative :)
Don't you just hate it when reserved names get in the way of what you want to call a variable; dir is my pet hate but id, str, and sum always cause minor annoyance too. :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.