If you are like me, a daily user of Sublime Text 3, then you will find this code snippet very handy. What if you will be able to just right click on a folder and the Explorer Context Menu will have an option to open that folder or file directly in Sublime Text 3?
The bellow code snippet will allow you to do just that. First open your favorite text editor and paste the code snippet bellow:
@echo off
SET st2Path=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\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 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
pause
Make sure that you set the correct path on line 2 the variable st2Path
Save the file with the name OpenWithSublimeText3.bat
. If your are running on windows 8.1, to launch the file just right click the file and chose “Run as administrator”.

If everything is ok you will see the following windows.

thanks a lot
You’re welcome
thanks its really helpful 😀
I’m glad that you find it helpful.
I have a small problem. It opens twice window Sublime. Thanks!
Sublime text remembers you last sessions. So please try to close all windows inside sublime, close sublime, and try again. Please let me know.
Works brilliantly on Windows 8, thank you!
Glad it helped.
It works but I must do it everytime. Excuse my bad English!
I think I’am found.
“hot_exit”: false
“remember_open_files”: false
in sublime-settings and it works.
Am I wrong ?
Thank you for your time.
No you’re not wrong…those setting disable the default way of sublime working with sessions after you close it.
Works a treat. Saves me loads of time. Had to smile at “open your favorite text editor” Notepad all the way 🙂
I’m glad to hear that.
is there way to add keyboard shortcut to open files/folder in sublime ?
Hi, thank you for your visit, I will look into it.
Thanks !!!
Thank you 🙂
Glad you like it 😀
Nice and simple guide helped me. Thanks a lot.
Glad you like it.
Awesome post!! Thanks
Glad you like it.
Thank you.
Hi Ben, thank you, glad I could be helpful.
I love you man :’)
Glad I could help you.
damn , it work , tks u man 😀
Glad to hear that
Thank you very much!
Glad you like it.
How to delete `Open with Sublime Text 3` from my recycle bin? Thanks
Hi, there is no option to delete the Open with Sublime Text 3 from the context menu of the recycle bin, since Windows, doesn’t give the option choose the context menu for which this customization should apply. I’m sorry.
A little cross-posting-aroo going on here but, this is a way to associate common filetypes with Sublime 3: http://superuser.com/questions/841497/windows-open-with-application-not-appearing-as-an-option/1020255#1020255
Thank you! This works like a charm
this open a file named “%1” whether I opened a file or a folder, so if you encounter the same problem, what I did is just replacing the “%%1” to “%1” to make it works in win10.
Excellent man Thank you so much! God bless you 🙂
Glad you found this useful
Perfect! Thank you.
Glad to hear that.
Thank You!
Glad it helped you