Sublime Forum

Right click, open folder with sublime text

#1

Salutations,

I often find myself browsing trough the Windows Explorer, and finding a folder I’d like to open with Sublime Text, I then have to go back to Sublime and navigate to that folder again trough the open folder browsing dialog. It would be much easier to have a right click on folder -> *select “Open Folder in Subline Text 2”**option, similar to what files have, but for folders:

What do you think? Is this easily doable or useful?

I think it would have massive-positive-ramifications.

Cheers

3 Likes

#2

Yes please! I second this. I would use it several times a day.

By the way, panev: in the absence of this feature, you could try dragging and dropping the folder into an already-open Sublime Text window. At least that way you don’t have to use the folder browsing dialog.

0 Likes

#3

Certainly, but most times I already have an open folder and the new folder gets dropped on top of the already-opened one and things get a bit messy.

Glad to see I’m not the only one needing this :smile:

0 Likes

#4

+1 :smile:

0 Likes

#5

I arrived at this post with the same question, and found this: gist.github.com/mrchief/5628677

Save this as a batch file, edit it to reflect your Sublime installation folder and whatever name you want in the context menu, then run it!

[code]@echo off
SET st2Path=C:\Program Files\Sublime Text 2\sublime_text.exe

rem add it for all file types
@reg add “HKEY_CLASSES_ROOT*\shell\Open with Sublime Text 2” /t REG_SZ /v “” /d “Open with Sublime Text 2” /f
@reg add “HKEY_CLASSES_ROOT*\shell\Open with Sublime Text 2” /t REG_EXPAND_SZ /v “Icon” /d “%st2Path%,0” /f
@reg add “HKEY_CLASSES_ROOT*\shell\Open with Sublime Text 2\command” /t REG_SZ /v “” /d "%st2Path% “%%1"” /f

rem add it for folders
@reg add “HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2” /t REG_SZ /v “” /d “Open with Sublime Text 2” /f
@reg add “HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2” /t REG_EXPAND_SZ /v “Icon” /d “%st2Path%,0” /f
@reg add “HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2\command” /t REG_SZ /v “” /d "%st2Path% “%%1"” /f
pause[/code]

If you mess up (like I did), change the file as follows to delete the entries:

@echo off @reg delete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" @reg delete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" @reg delete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2\command" @reg delete "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" @reg delete "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" @reg delete "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2\command"

1 Like

#6

I used to do the right click, since the time on that a friend of mine, namely Caesar, taught me about it. :wink:


I love wearing fingerless sap gloves.

0 Likes

#7

This is a need. Atom text editor has this option already and I think is useful because I miss it in ST3.

0 Likes

#8

In the meantime, you can click File > New Window within Sublime Text 2, and then simply drag the folder in question into Sublime :smile:

0 Likes

#9

Oh yes, I need this a lot as well, please integrate it in Sublime Text 2 (and 3).

0 Likes

#10

Until it’s implemented in ST, you can achieve it easily with a .reg script:

Windows Registry Editor Version 5.00

; For folders.

[HKEY_CLASSES_ROOT\Directory\shell\sublime]
@="&Open folder with Sublime Text"
"Icon"="\"C:\\Program Files\\SublimeText\\sublime_text.exe\",0"

[HKEY_CLASSES_ROOT\Directory\shell\sublime\command]
@="\"C:\\Program Files\\SublimeText\\sublime_text.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\sublime]
@="&Open folder with Sublime Text"
"Icon"="\"C:\\Program Files\\SublimeText\\sublime_text.exe\",0"

[HKEY_CLASSES_ROOT\Directory\Background\shell\sublime\command]
@="\"C:\\Program Files\\SublimeText\\sublime_text.exe\" \"%V\""

; For files.

[HKEY_CLASSES_ROOT\*\shell\sublime]
@="&Open with Sublime Text"
"Icon"="\"C:\\Program Files\\SublimeText\\sublime_text.exe\",0"

[HKEY_CLASSES_ROOT\*\shell\sublime\command]
@="\"C:\\Program Files\\SublimeText\\sublime_text.exe\" \"%1\""

In the above script, modify the Sublime Text directory to yours and save with the name sublime-text.reg. Then run by double clicking.

It adds 2 right click menus for folders:

  • folder’s right click menu
  • inside the folder, empty area right click menu

And it adds a right click menu for files. You can omit those lines if you already have that.

Also ST icons are added for menu items.

You can customize/localize menu text as you prefer.

0 Likes

#11

I know, impala454 already posted such a script. I just wanted to add my vote that this should get implemented in Sublime Text by default :).

0 Likes

#12

Why do you delete the same entry twice?

@reg delete “HKEY_CLASSES_ROOT*\shell\Open with Sublime Text 2”

0 Likes

#13

you can vote on this feature request here

0 Likes