Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Open folders and files with Sublime Text 3 from windows explorer context menu (tested in Windows 7)
@echo off
SET st3Path=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 "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%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 "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
pause
@andriuhatm

This comment has been minimized.

Copy link

andriuhatm commented Feb 28, 2015

Very nice!
Worked well on Win 8.1 ..

@tanbro

This comment has been minimized.

Copy link

tanbro commented May 15, 2015

nice work!

@EldonMcGuinness

This comment has been minimized.

Copy link

EldonMcGuinness commented May 21, 2015

Doesn't seem to work as expected for me. (Windows 7 x64)
I had to replace the %%1 with %1, else it would just open a file named "%1"

Cheers!

@aikusuma

This comment has been minimized.

Copy link

aikusuma commented May 27, 2015

it work with win8 64bit!
thanks!

@jasonwzs

This comment has been minimized.

Copy link

jasonwzs commented Jun 1, 2015

Works well on windows 7. Good job!

@patoncrispy

This comment has been minimized.

Copy link

patoncrispy commented Jul 13, 2015

Very cool. Thanks!

@mrjawapa

This comment has been minimized.

Copy link

mrjawapa commented Jul 22, 2015

Worked perfectly!

Thanks!

@littlee

This comment has been minimized.

Copy link

littlee commented Aug 9, 2015

Thanks a lot, it works well.
But can you add some fiter to it, because when I right click the recycle bin, it also shows in context menu

@jontemalm

This comment has been minimized.

Copy link

jontemalm commented Aug 15, 2015

Works good in Win 10 as well!

@alebaffa

This comment has been minimized.

Copy link

alebaffa commented Oct 28, 2015

Great, thanks man! I confirm it works on Win10!

@zamboney

This comment has been minimized.

Copy link

zamboney commented Nov 9, 2015

+1 working on window 10

@arunagnihotri

This comment has been minimized.

Copy link

arunagnihotri commented Dec 10, 2015

+1 Works on Window 8.1 64-bit

@hcchen

This comment has been minimized.

Copy link

hcchen commented Dec 21, 2015

good script,tks!

@huangyou

This comment has been minimized.

Copy link

huangyou commented Dec 23, 2015

Nice work, Thank you!

@jerryhall

This comment has been minimized.

Copy link

jerryhall commented Dec 31, 2015

This works great but, adds more clicks to the process (right click, select, click OK on user control popup - then see document) which is cumbersome (don't get to use that word often:). How can we get the ability to open via file association? I had 2 but, after installing 3 64-bit and uninstalling 2 I'm not able to associate any files (eg .css) through the traditional windows file association interface. Thanks!

@User1m

This comment has been minimized.

Copy link

User1m commented Jan 8, 2016

Works great on Windows 10 on Surface too. Thanks!

@relipse

This comment has been minimized.

Copy link

relipse commented Jan 9, 2016

very nice!

@alekseyl1992

This comment has been minimized.

Copy link

alekseyl1992 commented Jan 9, 2016

Thanks a lot.
But is it possible to Open current folder in Sublime?
(like a Git Bash here command)

@relipse

This comment has been minimized.

Copy link

relipse commented Jan 11, 2016

@alekseyl1992 good point, is there a way to utilize right clicking while already in a folder?

@ctian1

This comment has been minimized.

Copy link

ctian1 commented Jan 15, 2016

@alekseyl1992 @relipse yes, I've figured it out:

rem add it for inside folders
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3"         /t REG_SZ /v "" /d "Open with Sublime Text 3"   /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3"         /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
@marcusabu

This comment has been minimized.

Copy link

marcusabu commented Jan 15, 2016

@pangeacake

Didn't work for me, this did:
Replacing "C:\Program Files (x86)\Sublime Text 3\sublime_text.exe" "%1" by "C:\Program Files (x86)\Sublime Text 3\sublime_text.exe" "%V".

@cstewart90

This comment has been minimized.

Copy link

cstewart90 commented Jan 22, 2016

@fedriz

This comment has been minimized.

Copy link

fedriz commented Feb 12, 2016

Works on Windows 10! Thanks!

@georgetour

This comment has been minimized.

Copy link

georgetour commented Feb 15, 2016

Yup it works great Windows 10 Pro 64bit.Thank you.

@ghost

This comment has been minimized.

Copy link

ghost commented Feb 22, 2016

Great Thank you

@mstajnc

This comment has been minimized.

Copy link

mstajnc commented Mar 1, 2016

works great, thanks

@mfathirirhas

This comment has been minimized.

Copy link

mfathirirhas commented Mar 6, 2016

this open a file named '%1' whether I opened a folder or a file, so if you encounter the same problem, what I did is just change the "%%1" to "%1" to make it works in win10.

@amagyar

This comment has been minimized.

Copy link

amagyar commented Mar 12, 2016

Does it keep opening two sublimes to you? Sublime saves the last folder opened and open the last and the one I want to.

@LaxminarayanaDasari

This comment has been minimized.

Copy link

LaxminarayanaDasari commented Mar 18, 2016

Thanks it's working in 8.1 64 bit too.. thanks..

@JCaraballo113

This comment has been minimized.

Copy link

JCaraballo113 commented Mar 21, 2016

To stop it from opening two sublimes add this to your settings-user file:

"remember_open_files": false, "hot_exit": false

@zouyang08

This comment has been minimized.

Copy link

zouyang08 commented Mar 23, 2016

Thanks, works on windows 10.
But i think this is better, OpenWithSublimeText.bat

rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text"         /t REG_SZ /v "" /d "Open with Sublime Text"   /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text"         /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
@Scarwolf

This comment has been minimized.

Copy link

Scarwolf commented Apr 3, 2016

Works very well, thank you.

@wpboss

This comment has been minimized.

Copy link

wpboss commented Apr 6, 2016

Works is very well, thank you.

@dywangshsf

This comment has been minimized.

Copy link

dywangshsf commented Apr 13, 2016

nice job ! works on Win 10

@nvnghia

This comment has been minimized.

Copy link

nvnghia commented Apr 23, 2016

Thank you!

@hcristi

This comment has been minimized.

Copy link

hcristi commented Apr 27, 2016

Working on Win 7.
Thank you!

@Albhaku

This comment has been minimized.

Copy link

Albhaku commented Apr 29, 2016

Hey... this gives me a lot of "Access Denied". Any help? Thanks 👍

@jpehman

This comment has been minimized.

Copy link

jpehman commented May 11, 2016

Awesome! 👍 I also changed the %%1 to %1 on Win7 x64

@bgeVam

This comment has been minimized.

Copy link

bgeVam commented May 13, 2016

Thank you!

@electronthemes-user

This comment has been minimized.

Copy link

electronthemes-user commented May 30, 2016

Not working in WINDOWS 10

@renatoch

This comment has been minimized.

Copy link

renatoch commented May 31, 2016

Works great! 👍 I also changed the %%1 to %1 on Win10 x64

@j492

This comment has been minimized.

Copy link

j492 commented Jun 1, 2016

try this for win 10. Copy following to sublime.reg file and double click the reg file and import.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT*\shell\Sublime Text 3]
@="Open with Sublime Text 3"
"Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,
00,46,00,69,00,6c,00,65,00,73,00,5c,00,53,00,75,00,62,00,6c,00,69,00,6d,00,
65,00,20,00,54,00,65,00,78,00,74,00,20,00,33,00,5c,00,73,00,75,00,62,00,6c,
00,69,00,6d,00,65,00,5f,00,74,00,65,00,78,00,74,00,2e,00,65,00,78,00,65,00,
00,00

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

@iamstratos

This comment has been minimized.

Copy link

iamstratos commented Jun 1, 2016

Windows 8, worked fine. Thank you!

@ghost

This comment has been minimized.

Copy link

ghost commented Jun 2, 2016

Amazing. Windows 7. Thanks a ton!

@Pseudocrat

This comment has been minimized.

Copy link

Pseudocrat commented Jun 11, 2016

How would I adapt that initial bat script to delete the reg keys created by the script?

@Jhoow13

This comment has been minimized.

Copy link

Jhoow13 commented Jun 14, 2016

thanks man !
worked on windows 10.

@pirDOL

This comment has been minimized.

Copy link

pirDOL commented Jun 16, 2016

thx, worked on win7 professional sp1 x64

@HKhademian

This comment has been minimized.

Copy link

HKhademian commented Jun 24, 2016

This is a better command. save it to a bat file in app directory and run as administrator.
U can use this command for another applications like Atom,VSCode,... simply by changing App* lines

@echo off
SET AppKey=SublimeText3
SET AppTitle=Open with Sublime Text 3
SET AppPath=%~dp0sublime_text.exe
SET AppIcon=%AppPath%,0

REG ADD "HKEY_CLASSES_ROOT\*\shell\%AppKey%" /ve /f /d "%AppTitle%"
REG ADD "HKEY_CLASSES_ROOT\*\shell\%AppKey%" /v "Icon" /f /d "%AppIcon%"
REG ADD "HKEY_CLASSES_ROOT\*\shell\%AppKey%\command" /ve /f /d "%AppPath% \"%%1\""

REG ADD "HKEY_CLASSES_ROOT\Folder\shell\%AppKey%" /ve /f /d "%AppTitle%"
REG ADD "HKEY_CLASSES_ROOT\Folder\shell\%AppKey%" /v "Icon" /f /d "%AppIcon%"
REG ADD "HKEY_CLASSES_ROOT\Folder\shell\%AppKey%\command" /ve /f /d "%AppPath% \"%%v\""

REG ADD "HKEY_CLASSES_ROOT\Directory\Background\shell\%AppKey%" /ve /f /d "%AppTitle%"
REG ADD "HKEY_CLASSES_ROOT\Directory\Background\shell\%AppKey%" /v "Icon" /f /d "%AppIcon%"
REG ADD "HKEY_CLASSES_ROOT\Directory\Background\shell\%AppKey%\command" /ve /f /d "%AppPath% \"%%v\""
@poucotm

This comment has been minimized.

Copy link

poucotm commented Jun 26, 2016

Thank you. But use HKEY_CLASSES_ROOT\Directory instead of HKEY_CLASSES_ROOT\Folder in order to block popping up the context menu for the Trash

I've changed as the following:

Replace Code

@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe

rem remove original
@reg delete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text"        /f

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 "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f

rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text 3"         /t REG_SZ /v "" /d "Open with Sublime Text 3"   /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text 3"         /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f

@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3" /ve /f /d "Open with Sublime Text 3"
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3" /v "Icon" /f /d "%st3Path%,0"
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3\command" /ve /f /d "%st3Path% \"%%v\""

pause

Recover Code


@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe

rem reover original
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text"         /t REG_SZ /v "" /d "Open with Sublime Text"   /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f

rem remove
@reg delete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3"         /f
@reg delete "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text 3"         /f
@reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3" /f

pause
@pra-teek

This comment has been minimized.

Copy link

pra-teek commented Jun 28, 2016

thanks a lot bro.

@pyaf

This comment has been minimized.

Copy link

pyaf commented Jul 4, 2016

AWSOME !!

@pedroescalante

This comment has been minimized.

Copy link

pedroescalante commented Jul 17, 2016

Thanks man! worked perfectly on Windows 8 x64

@sheldonhull

This comment has been minimized.

Copy link

sheldonhull commented Jul 18, 2016

as a portable user, big help. Thanks for this

@KiT106

This comment has been minimized.

Copy link

KiT106 commented Aug 1, 2016

👍

@Kamilnaja

This comment has been minimized.

Copy link

Kamilnaja commented Aug 6, 2016

working good on windows 7 64, very useful!

@JustStayAlive

This comment has been minimized.

Copy link

JustStayAlive commented Aug 15, 2016

Thank you, very useful!

@flysofast

This comment has been minimized.

Copy link

flysofast commented Aug 21, 2016

Thank you, works well on Windows 10 x64

@hansnow

This comment has been minimized.

Copy link

hansnow commented Sep 21, 2016

thanks, works well on Win10 1511

@mlotfi2005

This comment has been minimized.

Copy link

mlotfi2005 commented Oct 3, 2016

How this bat file works ? I saved it, double clicked on it, it just opened a dos window saying

The operation completed successfully.
The operation completed successfully.
The operation completed successfully.
The operation completed successfully.
The operation completed successfully.
The operation completed successfully.
Press any key to continue . . .

when I clicked any key, it disappears.

@huyle2607

This comment has been minimized.

Copy link

huyle2607 commented Oct 7, 2016

Work like a charm on window 10. Thank you very much!

@rauldoliveira

This comment has been minimized.

Copy link

rauldoliveira commented Oct 12, 2016

Very nice!

@SiriusBits

This comment has been minimized.

Copy link

SiriusBits commented Oct 17, 2016

Windows 10 anniversary edition (August 2016) - needed to change "%%1" to "%1" as @mfathirirhas mentioned. After that - worked! Thank you!

@vancanhuit

This comment has been minimized.

Copy link

vancanhuit commented Oct 28, 2016

Work well on Windows 10 64-bit Anniversary Update. Thank you very much !

@ethaizone

This comment has been minimized.

Copy link

ethaizone commented Nov 2, 2016

Thx. It works very well. I just need only open st3 by directory.

@pavlo-fb

This comment has been minimized.

Copy link

pavlo-fb commented Nov 2, 2016

Works great on Windows 10 x64. Thanks!

@shafi49

This comment has been minimized.

Copy link

shafi49 commented Nov 7, 2016

works great on windows 10 x64 also. Thanks a lot

@loganmancuso

This comment has been minimized.

Copy link

loganmancuso commented Nov 28, 2016

you, sir, are amazing thank you (working from windows 10 x64) just extract and run as admin, voila perfect

@leotm

This comment has been minimized.

Copy link

leotm commented Dec 15, 2016

Even worked with my wife! Thank you

@jackoverflow

This comment has been minimized.

Copy link

jackoverflow commented Jan 7, 2017

mine is "Access Denied"

@Mohamed-Elwan

This comment has been minimized.

Copy link

Mohamed-Elwan commented Jan 12, 2017

@jackoverflow open it as administrator
it works very well on win10 x64

@ShineOfFire

This comment has been minimized.

Copy link

ShineOfFire commented Jan 13, 2017

@Mohamed-Elwan

@jackoverflow open it as administrator
it works very well on win10 x64

Me too on win10 x64
and @jackoverflow you need to "Run as Administrator"

@corepcn

This comment has been minimized.

Copy link

corepcn commented Jan 15, 2017

Fantastic. Works on Windows 10 1607.

@MrTruth0

This comment has been minimized.

Copy link

MrTruth0 commented Feb 15, 2017

Good, work on win 10 (with "Run as administrator"). Thanks ^^

@ageorgios

This comment has been minimized.

Copy link

ageorgios commented Feb 22, 2017

Windows 10 doesn't work, opens a file %1
so change the double %%1 to %1

@delzep

This comment has been minimized.

Copy link

delzep commented Feb 24, 2017

Great!, worked on windows 10 pro

@d-d22

This comment has been minimized.

Copy link

d-d22 commented Feb 26, 2017

where do i paste this ?? i dont get it.

@ghost

This comment has been minimized.

Copy link

ghost commented Feb 26, 2017

@d-d22

I think you paste the text into a text editor, save the result as batch (.bat) file, and run it.

What we really need, though, is better integration of Sublime into Windows's normal file association system. Or so it seems to me.

@BlueSun288

This comment has been minimized.

Copy link

BlueSun288 commented Feb 28, 2017

I made a version that works if Sublime Text is installed in Program Files(x86).
https://gist.github.com/BlueSun288/9639eb1a9937c5405e9dc1daf54de15d

@echo off
SET st3Path=C:\Program Files (x86)\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 "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%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 "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
pause
@mamu7211

This comment has been minimized.

Copy link

mamu7211 commented Mar 9, 2017

Thanks!

@Pacheco95

This comment has been minimized.

Copy link

Pacheco95 commented Mar 9, 2017

Thank you so much!

@lonelylab

This comment has been minimized.

Copy link

lonelylab commented Mar 17, 2017

Merci. Cela fonctionne très bien avec win10 64bit. :-)

@ykfq

This comment has been minimized.

Copy link

ykfq commented Mar 18, 2017

Ncie! Works for me in Win10 LTS

@eul721

This comment has been minimized.

Copy link

eul721 commented Mar 22, 2017

Works well. Thanks!

@khiconit

This comment has been minimized.

Copy link

khiconit commented Mar 30, 2017

Thanks

@JiyarDev

This comment has been minimized.

Copy link

JiyarDev commented Mar 31, 2017

Thank you so much!

@jsuiker

This comment has been minimized.

Copy link

jsuiker commented Apr 3, 2017

Works in Windows 7 x64

@Charley1

This comment has been minimized.

Copy link

Charley1 commented Apr 14, 2017

Thank you for this !!
(Works great on Windows 10 as well !)

@goforgold

This comment has been minimized.

Copy link

goforgold commented Apr 26, 2017

what if I do not have admin right? is there a way a to setup just for my account without admin rights? I have Sublime Text 3 installed.

@bojack-codes

This comment has been minimized.

Copy link

bojack-codes commented May 9, 2017

is it possible for me to undo this?

@HybridLizard

This comment has been minimized.

Copy link

HybridLizard commented May 10, 2017

Great gist. Thanks. Just need to open CMD as Administrator first and then call a script.

@Madhukar-Bandari

This comment has been minimized.

Copy link

Madhukar-Bandari commented May 15, 2017

where could i specify this batch file for Open folders and files with Sublime Text 3 from windows explorer context menu

@alator21

This comment has been minimized.

Copy link

alator21 commented May 24, 2017

Works fine in windows 10.Thank you.

@smileqingyuan

This comment has been minimized.

Copy link

smileqingyuan commented May 26, 2017

Works fine in win10.Thanks!

@adryx92

This comment has been minimized.

Copy link

adryx92 commented May 26, 2017

@poucotm thank you sir!

@cmosnick

This comment has been minimized.

Copy link

cmosnick commented Jun 2, 2017

👍 Windows 10

@tiagopotencia

This comment has been minimized.

Copy link

tiagopotencia commented Jun 9, 2017

Works on Windows 10 Creators Update!!

@anthonywigrimes

This comment has been minimized.

Copy link

anthonywigrimes commented Jun 12, 2017

@mlotif2005 - the batch runs an updates the registry. After the window closes, you can then right-click a folder or file and choose Open with Sublime Text 3.

@roundand - Thank you so much for this post.

@cholanmadala

This comment has been minimized.

Copy link

cholanmadala commented Jun 14, 2017

Awesome. Worked for me. I use Windows 10. Thanks!

@omega1990

This comment has been minimized.

Copy link

omega1990 commented Jun 16, 2017

Worked great on Windows10 x64
Thanks man!

@Shisuki

This comment has been minimized.

Copy link

Shisuki commented Jun 19, 2017

Works fine on Windows 10 Pro x64 Version 1703 Creators Update. Thanks man!

@axelitus

This comment has been minimized.

Copy link

axelitus commented Jul 10, 2017

I ended up with:

@echo off
set AppKey=SublimeText3
set AppTitle=Open with Sublime Text 3
set AppPath=%~dp0sublime_text.exe
set AppIcon=%AppPath%,0

@reg add "HKEY_CLASSES_ROOT\*\shell\%AppKey%"           /t REG_SZ /ve /f /d "%AppTitle%"
@reg add "HKEY_CLASSES_ROOT\*\shell\%AppKey%"           /t REG_EXPAND_SZ /v "Icon" /f /d "%AppIcon%"
@reg add "HKEY_CLASSES_ROOT\*\shell\%AppKey%\command"   /t REG_SZ /ve /f /d "%AppPath% \"%%1\""

@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\%AppKey%"            /t REG_SZ /ve /f /d "%AppTitle%"
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\%AppKey%"            /t REG_EXPAND_SZ /v "Icon" /f /d "%AppIcon%"
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\%AppKey%\command"    /t REG_SZ /ve /f /d "%AppPath% \"%%v\""

@reg add "HKEY_CLASSES_ROOT\Directory\shell\%AppKey%"           /t REG_SZ /ve /f /d "%AppTitle%"
@reg add "HKEY_CLASSES_ROOT\Directory\shell\%AppKey%"           /t REG_EXPAND_SZ /v "Icon" /f /d "%AppIcon%"
@reg add "HKEY_CLASSES_ROOT\Directory\shell\%AppKey%\command"   /t REG_SZ /ve /f /d "%AppPath% \"%%v\""

@reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\%AppKey%"           /t REG_SZ /ve /f /d "%AppTitle%"
@reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\%AppKey%"           /t REG_EXPAND_SZ /v "Icon" /f /d "%AppIcon%"
@reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\%AppKey%\command"   /t REG_SZ /ve /f /d "%AppPath% \"%%v\""
@pvnprb

This comment has been minimized.

Copy link

pvnprb commented Jul 19, 2017

Awesome! Worked with Win8.1 64bit
Thanks bud !

@durrillj

This comment has been minimized.

Copy link

durrillj commented Aug 13, 2017

This works great however it adds the "Open with Sublime Text 3" context item to the recycle bin which I don't find useful. If like me you only wish for this to work on standard files and directories and not the recycle bin then this adjustment might work out a little better. NOTE: I have only tested this on Windows 10 64 bit so I'm not entirely sure how this will work for previous versions of windows. Just adjust the "st3Path=" to where ever you have sublime text installed to.

@echo off
SET st3Path=D:\Programs\Sublime Text\sublime_text.exe

rem add it to all file system objects
@reg add "HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Open with Sublime Text 3"         /t REG_SZ /v "" /d "Open with Sublime Text 3"   /f
@reg add "HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Open with Sublime Text 3"         /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f

rem add it for current folder
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3"         /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3"         /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%v\"" /f

pause
@v2up

This comment has been minimized.

Copy link

v2up commented Aug 16, 2017

Not perfect for Win 10. and how can I clear it ?

@mushfiqur-rahman

This comment has been minimized.

Copy link

mushfiqur-rahman commented Aug 21, 2017

Thanks a lot. It's nicely work on Windows 10 pro 64bit

@pedrostc

This comment has been minimized.

Copy link

pedrostc commented Aug 21, 2017

Thanks a lot. Worked flawlessly for windows 10 pro 64

@melloti

This comment has been minimized.

Copy link

melloti commented Aug 23, 2017

thanks, work on windows 10!!

@MakChan

This comment has been minimized.

Copy link

MakChan commented Sep 9, 2017

Thank you!

@kingRayhan

This comment has been minimized.

Copy link

kingRayhan commented Sep 15, 2017

Works in windows 10

@mehmetkz61

This comment has been minimized.

Copy link

mehmetkz61 commented Sep 16, 2017

works for windows 10, thanks.

@4sh3

This comment has been minimized.

Copy link

4sh3 commented Sep 17, 2017

Hi friends,

I have used the bat on windows 10 64b but when I open the folder with sublime appears 2 sublimes (Sublime 3 Build 3143). What can I do to open only 1?

Thanks

@samusaran

This comment has been minimized.

Copy link

samusaran commented Sep 18, 2017

Works on Win10. Thanks!

@maksymilianmakuch

This comment has been minimized.

Copy link

maksymilianmakuch commented Sep 23, 2017

Works on Win10 64bit. Thanks.

@Jason-Sy

This comment has been minimized.

Copy link

Jason-Sy commented Sep 26, 2017

Thanks works great!

@endlessbest

This comment has been minimized.

Copy link

endlessbest commented Sep 29, 2017

works like a charm, thanks

@jinyingtan

This comment has been minimized.

Copy link

jinyingtan commented Oct 3, 2017

+1 Works on windows 10

@kiarov

This comment has been minimized.

Copy link

kiarov commented Oct 4, 2017

It worked perfectly! Thank you!

@Huevos-y-Bacon

This comment has been minimized.

Copy link

Huevos-y-Bacon commented Oct 10, 2017

+1 Windows 10 64 bit. Beautiful! Thanks for posting this!

@satishp962

This comment has been minimized.

Copy link

satishp962 commented Oct 18, 2017

Thanks a lot. Worked on WIndows 10 Pro.

@aJoohongKim

This comment has been minimized.

Copy link

aJoohongKim commented Oct 20, 2017

Worked on Windows 10 Pro. Good!!

@tonyOP1985

This comment has been minimized.

Copy link

tonyOP1985 commented Oct 25, 2017

Works great on Windows 10! Thanks!!

@entimm

This comment has been minimized.

Copy link

entimm commented Oct 25, 2017

Worked on Windows 10 Pro. Good!!

@mittalyashu

This comment has been minimized.

Copy link

mittalyashu commented Oct 30, 2017

Everything works fine.

But I have one problem and that is if we select a directory and open in Sublime Text.
The probme is that it open's that directory in new sublime window.

I want to append that directory in the existing sublime window.

@fedek6

This comment has been minimized.

Copy link

fedek6 commented Nov 9, 2017

najsu!

If anyone would like to remove this integration use this: https://gist.github.com/fedek6/09ccbffc46fa2d41c734a7b1ef1d942c

@mikalauskas

This comment has been minimized.

Copy link

mikalauskas commented Nov 21, 2017

This is from the msi installer

sublime_shell.reg:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text]

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

@rmkrjy

This comment has been minimized.

Copy link

rmkrjy commented Dec 16, 2017

Thanks.. working well in windows 10

@kiingsway

This comment has been minimized.

Copy link

kiingsway commented Dec 20, 2017

Working here too
Windows 10 64bit

@Tarantulo

This comment has been minimized.

Copy link

Tarantulo commented Dec 28, 2017

Thx. Works great Win 10 x64

@ming0627

This comment has been minimized.

Copy link

ming0627 commented Jan 11, 2018

Thanks! Working in windows 10

@sail456852

This comment has been minimized.

Copy link

sail456852 commented Jan 28, 2018

Very helpful! thank you, I first thought using VIM as my example java project viewer. but it is not that easy in folder level. I tried NERDTree,
and :Explore even I am kind of hard-core VIM fan, I thought Sublime wins this time at least on Windows 10

@betapp

This comment has been minimized.

Copy link

betapp commented Feb 9, 2018

Thank you so much! Works for me in Windows 10 SP1! Only the application path i had to change.

@almohajire

This comment has been minimized.

Copy link

almohajire commented Feb 15, 2018

nice work!
Thank you so much!

@jvihrial

This comment has been minimized.

Copy link

jvihrial commented Feb 19, 2018

n00bie tip: run it as administrator , but really good stuff! (Ok with Windows 10 Pro)

@kocica

This comment has been minimized.

Copy link

kocica commented Mar 7, 2018

Win 10 works well, thanks.

@miqueiaspenha

This comment has been minimized.

Copy link

miqueiaspenha commented Apr 25, 2018

Thanks!

@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe

rem remove original
@reg delete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text"        /f

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 "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f

rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text 3"         /t REG_SZ /v "" /d "Open with Sublime Text 3"   /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text 3"         /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f

@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3" /ve /f /d "Open with Sublime Text 3"
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3" /v "Icon" /f /d "%st3Path%,0"
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3\command" /ve /f /d "%st3Path% \"%%v\""

pause

Windows 10 Pro.

@Ebram-Tharwat

This comment has been minimized.

Copy link

Ebram-Tharwat commented May 12, 2018

Thanks. It works well with Windows 10 Redstone 4 (build 17134.1) .

@SatishPatruni

This comment has been minimized.

Copy link

SatishPatruni commented Jun 16, 2018

nice.. works as expected on Win10 - I wanted it only for folders

@aasaadzaman5

This comment has been minimized.

Copy link

aasaadzaman5 commented Jun 19, 2018

It worked in windows 10. I loved it. Thank you so much.

@johnson100

This comment has been minimized.

Copy link

johnson100 commented Jun 21, 2018

Worked on Windows 10. Thanks.

@kimpeupeu

This comment has been minimized.

Copy link

kimpeupeu commented Jul 24, 2018

if you see only %1 filename, use this (i replace all %%1 to %1)

@echo off
SET st3Path=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 "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% "%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 "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% "%1"" /f
pause

@evuazeze

This comment has been minimized.

Copy link

evuazeze commented Aug 26, 2018

It works! thanks a lot.

@black-tribesman

This comment has been minimized.

Copy link

black-tribesman commented Sep 21, 2018

amazing

@gladius882

This comment has been minimized.

Copy link

gladius882 commented Oct 18, 2018

Simple and working! Good joob ;)
Works perfect on Win 8.1 pro x64

@werschrul

This comment has been minimized.

Copy link

werschrul commented Nov 10, 2018

Still working on W10 x64. Thanks!

@CDNRocket

This comment has been minimized.

Copy link

CDNRocket commented Nov 30, 2018

I've found a more complex solution that works also with admin privileges when used with the shift key.
sublimetext3-contextmenu

@spitutz

This comment has been minimized.

Copy link

spitutz commented Feb 16, 2019

thanks its work for me on windows 7 x64bit !

@kty0529

This comment has been minimized.

Copy link

kty0529 commented Mar 1, 2019

Thank you!

@HayeulTanjib

This comment has been minimized.

Copy link

HayeulTanjib commented May 12, 2019

Awesome!

@ThomIves

This comment has been minimized.

Copy link

ThomIves commented Aug 28, 2019

Thanks! Worked on Windows 10 Virtual Machine using VirtualBox.

@Userkz

This comment has been minimized.

Copy link

Userkz commented Sep 30, 2019

Nice Work

Windows 10, 64Bit

@Userkz

This comment has been minimized.

Copy link

Userkz commented Sep 30, 2019

Базар жоқ, менен қазақша коментарий. Жасап тұр

@Userkz

This comment has been minimized.

Copy link

Userkz commented Sep 30, 2019

how to remove the second? http://prntscr.com/pczh1f

@rmvaldesd

This comment has been minimized.

Copy link

rmvaldesd commented Nov 5, 2019

Thanks!
works fine in Windows 10 64bits.

@ovidiujordache

This comment has been minimized.

Copy link

ovidiujordache commented Dec 5, 2019

Hey... this gives me a lot of "Access Denied". Any help? Thanks

open cmd with admin privileges. cmd right click run as administrator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.