Sublime Forum

Open with Sublime Text 2 for folders

#1

Hey!

I am currently trying out sublime text and really like it.

I was wondering whether a feature could be added so that from the context menu I can open folders in sublime.

Greetings,
Thomas

P.S.: I hate the icon.

0 Likes

#2

You can add the folder to the project.

There is also a plugin called Dired that shows you a buffer with a directory listing and then you can open subdirs, or expand them, or open files.

bitbucket.org/hibbelig/dired

0 Likes

#3

Dired works fine, thank you for a cool idea.

It would be nice to have an option to reuse the same tab when navigating through folders.
And to have a global shortcut to switch to tab with Dired from any other tab.

0 Likes

#4

I don’t think you understood my request :frowning:

Usually I open single files via the Windows Explorer and use this neat feature:

When I try to open a folder though I don’t get that option:

0 Likes

#5

I was able to create a folder context menu entry (I copied a similar IrfanView entry), but Sublime Text doesn’t seem to do anything differently when passed a folder name.

What would you expect to happen when you open a folder?

0 Likes

#6

[quote=“ToddFiske”]I was able to create a folder context menu entry (I copied a similar IrfanView entry), but Sublime Text doesn’t seem to do anything differently when passed a folder name.

What would you expect to happen when you open a folder?[/quote]

I would expect to see a directory listing. Or perhaps that the directory is added to the side bar and the directory selected in the side bar. If there is a ST window that is looking at a project that contains the folder you clicked on, then that window should be focused and directories should be expanded to show the directory you attempted to open.

0 Likes

#7

You can try to run these commands from the command line (replace variable ${sublpathtoexe}).

reg delete "HKLM\SOFTWARE\Classes\Directory\shell\subl" /f 
reg add "HKLM\SOFTWARE\Classes\Directory\shell\subl" /t REG_SZ /ve /d "Open in Sublime Text"
# reg add "HKLM\SOFTWARE\Classes\Directory\shell\subl" /t REG_EXPAND_SZ /v "Icon" /d "${sublpathtoexe},0"
reg add "HKLM\SOFTWARE\Classes\Directory\shell\subl\command" /t REG_SZ /ve /d "${sublpathtoexe} --new-window \"%1\" "
0 Likes

#8

@atomi: that’s basically what I did, but with this registry script:

[code]Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Open Folder with &Sublime Text 2]
@=“Open Folder with &Sublime Text 2”

[HKEY_CLASSES_ROOT\Directory\shell\Open Folder with &Sublime Text 2\command]
@="“C:\SublimeText2\sublime_text.exe” “%1"”
[/code]

note: edit sublime path above

Problem is it doesn’t do anything relative to the folder you start it from, even your variation of using --new-window. If you press Ctrl+O after it opens, it is not necessarily the folder that you right-clicked on. For me it always opens up to my user package folder.

0 Likes

#9

Drag-n-drop directory to ST does not fit your needs?

0 Likes

#10

Well what do you know! It works just fine, and the registry entry works the same way, but I didn’t have the sidebar open so I didn’t see it. File Open still comes up to another folder, but the sidebar is way easier. Thanks for pointing it out.

0 Likes

#11

Good idea with drag’n’drop folder.
May I ask you how to do the same thing but in context menu of file manager in Ubuntu.

0 Likes

#12

Expanding on the other submission, here’s a few .reg files for the default install location. It also adds the sublime icon on the option as well as add the option when you right click the explorer background when inside a folder. Use “Right click > Save link as” for the following links.

https://raw.githubusercontent.com/Zren/SublimeMisc/master/OpenFolderInSublimeText2_x86.reg

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Open Folder in Sublime Text 2]
@="Open Folder in Sublime Text 2"
"Icon"="\"C:\\Program Files (x86)\\Sublime Text 2\\sublime_text.exe\""

[HKEY_CLASSES_ROOT\Directory\shell\Open Folder in Sublime Text 2\command]
@="\"C:\\Program Files (x86)\\Sublime Text 2\\sublime_text.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\Open Folder in Sublime Text 2]
@="Open Folder in Sublime Text 2"
"Icon"="\"C:\\Program Files (x86)\\Sublime Text 2\\sublime_text.exe\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\Open Folder in Sublime Text 2\command]
@="\"C:\\Program Files (x86)\\Sublime Text 2\\sublime_text.exe\" \"%V\""

https://raw.githubusercontent.com/Zren/SublimeMisc/master/OpenFolderInSublimeText2_x64.reg

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Open Folder in Sublime Text 2]
@="Open Folder in Sublime Text 2"
"Icon"="\"C:\\Program Files\\Sublime Text 2\\sublime_text.exe\""

[HKEY_CLASSES_ROOT\Directory\shell\Open Folder in Sublime Text 2\command]
@="\"C:\\Program Files\\Sublime Text 2\\sublime_text.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\Open Folder in Sublime Text 2]
@="Open Folder in Sublime Text 2"
"Icon"="\"C:\\Program Files\\Sublime Text 2\\sublime_text.exe\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\Open Folder in Sublime Text 2\command]
@="\"C:\\Program Files\\Sublime Text 2\\sublime_text.exe\" \"%V\""

Edit: JeroenVdb sent a PR to include files for ST3, so I’ll post them here for convenience.

https://raw.githubusercontent.com/Zren/SublimeMisc/master/OpenFolderInSublimeText3_x86.reg

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Open Folder in Sublime Text 3]
@="Open Folder in Sublime Text 3"
"Icon"="\"C:\\Program Files (x86)\\Sublime Text 3\\sublime_text.exe\""

[HKEY_CLASSES_ROOT\Directory\shell\Open Folder in Sublime Text 3\command]
@="\"C:\\Program Files (x86)\\Sublime Text 3\\sublime_text.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\Open Folder in Sublime Text 3]
@="Open Folder in Sublime Text 3"
"Icon"="\"C:\\Program Files (x86)\\Sublime Text 3\\sublime_text.exe\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\Open Folder in Sublime Text 3\command]
@="\"C:\\Program Files (x86)\\Sublime Text 3\\sublime_text.exe\" \"%V\""

https://raw.githubusercontent.com/Zren/SublimeMisc/master/OpenFolderInSublimeText3_x64.reg

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Open Folder in Sublime Text 3]
@="Open Folder in Sublime Text 3"
"Icon"="\"C:\\Program Files\\Sublime Text 3\\sublime_text.exe\""

[HKEY_CLASSES_ROOT\Directory\shell\Open Folder in Sublime Text 3\command]
@="\"C:\\Program Files\\Sublime Text 3\\sublime_text.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\Open Folder in Sublime Text 3]
@="Open Folder in Sublime Text 3"
"Icon"="\"C:\\Program Files\\Sublime Text 3\\sublime_text.exe\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\Open Folder in Sublime Text 3\command]
@="\"C:\\Program Files\\Sublime Text 3\\sublime_text.exe\" \"%V\""
0 Likes