Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add "Open with Sublime Text 2" to Windows Explorer Context Menu (including folders)

MIT License

Copyright (c) [year] [fullname]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@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
@viktorlindgren

This comment has been minimized.

Copy link

@viktorlindgren viktorlindgren commented Jun 9, 2013

THX

@ahrib

This comment has been minimized.

Copy link

@ahrib ahrib commented Jun 17, 2013

Thanks, this is awesome

@bjerkins

This comment has been minimized.

Copy link

@bjerkins bjerkins commented Jul 31, 2013

Thanks!

@elliotwoods

This comment has been minimized.

Copy link

@elliotwoods elliotwoods commented Aug 7, 2013

great

@erikcox

This comment has been minimized.

Copy link

@erikcox erikcox commented Aug 8, 2013

Works perfect. Even has an icon; nice touch. Thanks!

@helpse

This comment has been minimized.

Copy link

@helpse helpse commented Aug 15, 2013

Incredible :)

@jukebox017

This comment has been minimized.

Copy link

@jukebox017 jukebox017 commented Aug 20, 2013

At first, I got a bunch of access denieds.
But then I ran it as an administrator.
Silly Windows 7 :)

@rhali786

This comment has been minimized.

Copy link

@rhali786 rhali786 commented Sep 11, 2013

The icon isn't showing for me..
SET st2Path=C:\Program Files\Sublime Text 2\sublime_text.exe
@reg add "HKEY_CLASSES_ROOT*\shell\Open with Sub
lime Text 2" .gitk /t REG_EXPAND_SZ /v "Icon" /d "%~dp0sublime_text.exe,0" /f

Completes successfully, but C:\Program Files\Sublime Text 2\sublime_text.exe,0 does not result in an icon.

@pebreo

This comment has been minimized.

Copy link

@pebreo pebreo commented Sep 21, 2013

Excellent! Thanks for sharing this

@phoenixstudio

This comment has been minimized.

Copy link

@phoenixstudio phoenixstudio commented Sep 23, 2013

thanks!

@rubenbristian

This comment has been minimized.

Copy link

@rubenbristian rubenbristian commented Sep 27, 2013

Thanks! This is a really great addition to Sublime Text!

@romdim

This comment has been minimized.

Copy link

@romdim romdim commented Oct 10, 2013

Thank you!!!

@samuelmf

This comment has been minimized.

Copy link

@samuelmf samuelmf commented Oct 25, 2013

Excellent, works for Sublime Text 3 too, just changing the program path. Thanks

@philippotto

This comment has been minimized.

Copy link

@philippotto philippotto commented Nov 3, 2013

thanks!

@colingaj

This comment has been minimized.

Copy link

@colingaj colingaj commented Nov 5, 2013

Excellent!

@albertinix

This comment has been minimized.

Copy link

@albertinix albertinix commented Nov 7, 2013

Thanks! Quick'n'dirty solution, just what I needed.

@jcramirez

This comment has been minimized.

Copy link

@jcramirez jcramirez commented Nov 19, 2013

Thank you, this works very nicely. Keep up the good work.

@aguirrem

This comment has been minimized.

Copy link

@aguirrem aguirrem commented Jan 5, 2014

Short and simple. Thank you!

@JunaidQadirB

This comment has been minimized.

Copy link

@JunaidQadirB JunaidQadirB commented Jan 9, 2014

I'm on win8.1 so I had to add things manually to the Registry.
Here's the exported reg file in case you are on a windows with Registry Editor v5:

Please make sure your ST2 installation paths match.

file: st2_shell.reg

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2]
@="Open with Sublime Text 2"
"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,32,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,\
  2c,00,30,00,00,00

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

[HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2]
@="Open with Sublime Text 2"
"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,32,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,\
  2c,00,30,00,00,00

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

please don't hold me responsible in case of any incident.

@jcppkkk

This comment has been minimized.

Copy link

@jcppkkk jcppkkk commented Jan 9, 2014

​Improved Version

  • ​Open File with Sublime Text
  • ​Open File with Sublime Text as Admin
  • ​Open Folder with Sublime Text
    ​Execute .bat Script where Sublime Text installed.

https://gist.github.com/jcppkkk/8330314

@bruno-gelb

This comment has been minimized.

Copy link

@bruno-gelb bruno-gelb commented Jan 12, 2014

works just fine :) for #st3 you just need to replace all these '2' to '3'.

@leonardinius

This comment has been minimized.

Copy link

@leonardinius leonardinius commented Jan 22, 2014

Thanx

@treckstar

This comment has been minimized.

Copy link

@treckstar treckstar commented Feb 10, 2014

This is fantastic, thanks!

@LongYC

This comment has been minimized.

Copy link

@LongYC LongYC commented Feb 14, 2014

Thank you for sharing, you saved us a lot of time.

@ExtremeGTX

This comment has been minimized.

Copy link

@ExtremeGTX ExtremeGTX commented Feb 19, 2014

Works Great, Thanks

@volyx

This comment has been minimized.

Copy link

@volyx volyx commented Feb 20, 2014

Thnx!

@braceandbracket

This comment has been minimized.

Copy link

@braceandbracket braceandbracket commented Feb 27, 2014

Solid work sir!

@dejwid

This comment has been minimized.

Copy link

@dejwid dejwid commented Mar 2, 2014

I love you, mate!

@awahlig

This comment has been minimized.

Copy link

@awahlig awahlig commented Mar 6, 2014

I'm also using the "--new-window" argument to open the file in a new window. I usually have my project open in sublime and I usually don't want other files appearing there.

@cainux

This comment has been minimized.

Copy link

@cainux cainux commented Mar 22, 2014

Thanks so much for this!

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Mar 30, 2014

Thanks!

@pingxumeng

This comment has been minimized.

Copy link

@pingxumeng pingxumeng commented Apr 18, 2014

Works fine . thanks

@marcelodeandrade

This comment has been minimized.

Copy link

@marcelodeandrade marcelodeandrade commented May 19, 2014

Thank's a lot!

@igal-getrailo

This comment has been minimized.

Copy link

@igal-getrailo igal-getrailo commented Jun 30, 2014

This is great, thanks!

See also https://gist.github.com/jcppkkk/8330314 which adds an option to Open As Administrator

@kristinpeterson

This comment has been minimized.

Copy link

@kristinpeterson kristinpeterson commented Jul 2, 2014

Just what I was looking for, thanks!!!

@hiun

This comment has been minimized.

Copy link

@hiun hiun commented Jul 20, 2014

You rocks!!!

@bayrock

This comment has been minimized.

Copy link

@bayrock bayrock commented Jul 28, 2014

Thanks for this. Does anyone know how I can remove the context menu from certain extensions? For example I don't need to open the Recycle Bin with Sublime.

Or maybe limit it to certain extensions instead? For example so I could only add this context menu to .lua files.

Otherwise if that can't be done how could I change the order in which it appears? For example so that I could have 'Open with Sublime Text 3' appear underneath 'Empty Recycle Bin' to make it less prominent.

@PatrickMcDonald

This comment has been minimized.

Copy link

@PatrickMcDonald PatrickMcDonald commented Aug 5, 2014

@bayrock If you replace HKEY_CLASSES_ROOT\Folder\shell with HKEY_CLASSES_ROOT\Directory\shell then the Open with Sublime Text command only appears in the context menus of physical directories and not on virtual folders (like drives, Recycle Bin, Control Panel, etc.)

@mcdavsco

This comment has been minimized.

Copy link

@mcdavsco mcdavsco commented Aug 12, 2014

Thanks a lot. Works great for ST2

@ftobares

This comment has been minimized.

Copy link

@ftobares ftobares commented Aug 13, 2014

Thanks a lot! Very helpful !

@olanchuy

This comment has been minimized.

Copy link

@olanchuy olanchuy commented Sep 8, 2014

Can anyone tell me how to do this? where to add? a tutorial maybe? thanks :)

@sjurlur

This comment has been minimized.

Copy link

@sjurlur sjurlur commented Sep 9, 2014

Thanks!
olanchuy: download file, right click and select "run as administrator".

@rustamli

This comment has been minimized.

Copy link

@rustamli rustamli commented Sep 14, 2014

Awesome, thank you!

@zaccharles

This comment has been minimized.

Copy link

@zaccharles zaccharles commented Sep 22, 2014

Cool, works perfectly with Windows 7 and Sublime Text 3 (with path modification, of course). Thanks!

@lukaMis

This comment has been minimized.

Copy link

@lukaMis lukaMis commented Sep 24, 2014

Cool, works perfectly with Windows 7 and Sublime Text 3 (with path modification, of course).
Thanks!

+1

@EdwinSaenz

This comment has been minimized.

Copy link

@EdwinSaenz EdwinSaenz commented Sep 29, 2014

Worked perfectly for me and Sublime Text 3. Thank you!

@danielpsf

This comment has been minimized.

Copy link

@danielpsf danielpsf commented Oct 8, 2014

Thanks man!

@zur4ik

This comment has been minimized.

Copy link

@zur4ik zur4ik commented Oct 27, 2014

Works perfectly on Windows 8.1
Thanks a lot!

@Oussama-Tn

This comment has been minimized.

Copy link

@Oussama-Tn Oussama-Tn commented Oct 29, 2014

Hi, Thanks!
But, I'm having an issue.. when I close sublime and try to open another folder, it opens two windows: The last project and the new one. Any suggestion? Thanks

@ale87kb

This comment has been minimized.

Copy link

@ale87kb ale87kb commented Nov 4, 2014

Thanks!!

@nadirakdag

This comment has been minimized.

Copy link

@nadirakdag nadirakdag commented Dec 7, 2014

awesome thanks

@cberigan

This comment has been minimized.

Copy link

@cberigan cberigan commented Dec 18, 2014

Amazing. Thanks!!

@arshmakker

This comment has been minimized.

Copy link

@arshmakker arshmakker commented Dec 23, 2014

awesome dude... thanks.. pushes me to switch to sublime... more and more

@ekosukmo

This comment has been minimized.

Copy link

@ekosukmo ekosukmo commented Dec 26, 2014

WORK for me. Is possible to replace "Open with Sublime Text 3" with my own languange? thanks

@gccpacman

This comment has been minimized.

Copy link

@gccpacman gccpacman commented Jan 1, 2015

it works on my win8.1 x64, too. that is amazing!

@truongduyng

This comment has been minimized.

Copy link

@truongduyng truongduyng commented Jan 10, 2015

thanks, pro! But if I want to remove it, how can i do?

@arnaudoff

This comment has been minimized.

Copy link

@arnaudoff arnaudoff commented Jan 11, 2015

Thanks, amazing.

@nitin7dc

This comment has been minimized.

Copy link

@nitin7dc nitin7dc commented Jan 14, 2015

thanks

@aronayne

This comment has been minimized.

Copy link

@aronayne aronayne commented Jan 22, 2015

Extremely handy, thanks.

@CJEdgerton

This comment has been minimized.

Copy link

@CJEdgerton CJEdgerton commented Feb 11, 2015

Arigatou muchos! The open folder context menu has been such a pain to navigate on Windows, this is a great solution.

@squarewave24

This comment has been minimized.

Copy link

@squarewave24 squarewave24 commented Feb 17, 2015

worked like a charm, thanks!

@nssy

This comment has been minimized.

Copy link

@nssy nssy commented Feb 20, 2015

Much appreciated.

@elbym

This comment has been minimized.

Copy link

@elbym elbym commented Feb 23, 2015

Super Handy! Thank you very much.

@SteveBlodgett

This comment has been minimized.

Copy link

@SteveBlodgett SteveBlodgett commented Mar 18, 2015

Thank you.

@hwdegroot

This comment has been minimized.

Copy link

@hwdegroot hwdegroot commented Mar 27, 2015

Thanks. Works like a charm

@hulinghuan

This comment has been minimized.

Copy link

@hulinghuan hulinghuan commented Mar 31, 2015

Work as expected! Thanks!

@folger

This comment has been minimized.

Copy link

@folger folger commented Apr 1, 2015

Thanks very much!

@ronammar

This comment has been minimized.

Copy link

@ronammar ronammar commented Apr 2, 2015

Beauty!

@MohamedMahmoud299

This comment has been minimized.

Copy link

@MohamedMahmoud299 MohamedMahmoud299 commented Apr 6, 2015

Amazing!

@DanielGGordon

This comment has been minimized.

Copy link

@DanielGGordon DanielGGordon commented Apr 17, 2015

Ah shoot I use sublime text 3 not 2. So now I actually have 2 options: open with sublime text 2 and 3. However they both do the same thing... How to fix?

@vitalii-vitrenko

This comment has been minimized.

Copy link

@vitalii-vitrenko vitalii-vitrenko commented May 9, 2015

I think in the last line should be %1 instead of %%1. No?

@nelreina

This comment has been minimized.

Copy link

@nelreina nelreina commented May 11, 2015

Many many tnxs

@alambley

This comment has been minimized.

Copy link

@alambley alambley commented May 20, 2015

Fantastic.

@gccpacman

This comment has been minimized.

Copy link

@gccpacman gccpacman commented May 22, 2015

Very useful thanks.
It also works with sublime text 3.

@tobiashochguertel

This comment has been minimized.

Copy link

@tobiashochguertel tobiashochguertel commented May 31, 2015

Thank you 😄

@atheiman

This comment has been minimized.

Copy link

@atheiman atheiman commented Jun 1, 2015

my god this is so much easier on a mac..

@D0zingcat

This comment has been minimized.

Copy link

@D0zingcat D0zingcat commented Jun 2, 2015

Tks! Awesome work! That helps me a lot! A little more easier XD

@pstoev

This comment has been minimized.

Copy link

@pstoev pstoev commented Jun 17, 2015

Here's the version for Sublime Text 3 with additional option that shows up when showing current folder's context menu. https://gist.github.com/pstoev/feaf7797cd795cff72a5

@abhisheksoni27

This comment has been minimized.

Copy link

@abhisheksoni27 abhisheksoni27 commented Jun 22, 2015

Works. Cheers!

@Juni4567

This comment has been minimized.

Copy link

@Juni4567 Juni4567 commented Jul 10, 2015

I have opened it several times and I see multiple lines of "open with sublime text 2" What should i do, please help!

@Juni4567

This comment has been minimized.

Copy link

@Juni4567 Juni4567 commented Jul 10, 2015

For those who has created multiple context menu items like me can fix here http://gamier.blogspot.com/2015/07/fix-multiple-context-menu-items-for-sublime-text.html

@accidentallyc

This comment has been minimized.

Copy link

@accidentallyc accidentallyc commented Jul 21, 2015

I really want to star this but for some reason it keeps giving " Something went wrong with that request. Please try again."

@katlimruiz

This comment has been minimized.

Copy link

@katlimruiz katlimruiz commented Aug 4, 2015

As is the original, it worked for win8.1.

very cool with icon!!!

@meichthys

This comment has been minimized.

Copy link

@meichthys meichthys commented Sep 10, 2015

As mentioned before, it worked for Sublime Text 3 - all i needed to do was change all the 2's to 3's in the file.

@mathisto

This comment has been minimized.

Copy link

@mathisto mathisto commented Sep 30, 2015

Thank you so much sir. This was very helpful.

@RaphaelSanches

This comment has been minimized.

Copy link

@RaphaelSanches RaphaelSanches commented Oct 10, 2015

Thank you so much, guy. This works perfectly on Windows 8 with Sublime Text 2.

@roguegerbil

This comment has been minimized.

Copy link

@roguegerbil roguegerbil commented Nov 19, 2015

With edits for Sublime Text 3 and directories (vs. folders) -

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

rem add it for directories
@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 "%st3fqfn%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3fqfn% \"%%1\"" /f

pause

Works great on Windows 8 Pro.

Thanks mrchief for the original submission!

@trungtin

This comment has been minimized.

Copy link

@trungtin trungtin commented Nov 23, 2015

including directory background :)

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

rem add it for directories
@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 "%st3fqfn%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3fqfn% \"%%1\"" /f

rem add it for directories background
@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 "%st3fqfn%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3fqfn% \"%%V\"" /f
pause
@BernardoGO

This comment has been minimized.

Copy link

@BernardoGO BernardoGO commented Nov 29, 2015

Thank you

@nico78

This comment has been minimized.

Copy link

@nico78 nico78 commented Dec 17, 2015

perfect, Thanks

@mtalis

This comment has been minimized.

Copy link

@mtalis mtalis commented Dec 23, 2015

It works! Thanks you!

@kiglaze

This comment has been minimized.

Copy link

@kiglaze kiglaze commented Dec 28, 2015

Hi, I saved this .bat file on my computer and ran it from the cmd window. It said "ERROR: Access is denied." six times. How do I get around this?? Thank you.

@chalubhalu

This comment has been minimized.

Copy link

@chalubhalu chalubhalu commented Jan 4, 2016

@kiglaze You need administrator privilege to modify registry keys. Run you cmd in admin mode.

@steven-lam

This comment has been minimized.

Copy link

@steven-lam steven-lam commented Jan 15, 2016

Got it to work with sublime text 3; Thanks a lot!

@thesafetylemur

This comment has been minimized.

Copy link

@thesafetylemur thesafetylemur commented Feb 5, 2016

Worked like a charm. Thanks!

@Nabnab9

This comment has been minimized.

Copy link

@Nabnab9 Nabnab9 commented Feb 11, 2016

Thanks, works great !

@HellfireXD

This comment has been minimized.

Copy link

@HellfireXD HellfireXD commented Feb 24, 2016

For PowerShell fans, I have created a PowerShell script based on the registry entries in this script as well as a few forks.
Unfortunately i cannot fork to another file type.

https://gist.github.com/HellfireXD/7f8c5a0845a44dfa9e7d

@jreigel

This comment has been minimized.

Copy link

@jreigel jreigel commented Mar 3, 2016

Awesome. Thanks for sharing.

@jaroberts-krittermedia-com

This comment has been minimized.

Copy link

@jaroberts-krittermedia-com jaroberts-krittermedia-com commented Mar 30, 2016

without admin right, boo, no luck

@gurkan0791

This comment has been minimized.

Copy link

@gurkan0791 gurkan0791 commented Apr 3, 2016

Thanks. work win10

@troyxuanyichen

This comment has been minimized.

Copy link

@troyxuanyichen troyxuanyichen commented Apr 25, 2016

It's really cool! You just have to modify the path of your sublime.Thanks!

@AmirGeorge

This comment has been minimized.

Copy link

@AmirGeorge AmirGeorge commented May 7, 2016

This is very useful, thanks a lot!

@shawnthompson

This comment has been minimized.

Copy link

@shawnthompson shawnthompson commented Jun 23, 2016

Thank you very much 👍

@HKhademian

This comment has been minimized.

Copy link

@HKhademian HKhademian commented Jun 24, 2016

(from my other gist comment)
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\""
@hasham7861

This comment has been minimized.

Copy link

@hasham7861 hasham7861 commented Aug 14, 2016

👍

@pksingh-pro

This comment has been minimized.

Copy link

@pksingh-pro pksingh-pro commented Dec 29, 2016

Works like a charm. Excellent work.

@Dengjiansheng

This comment has been minimized.

Copy link

@Dengjiansheng Dengjiansheng commented Jan 9, 2017

Thank you

@aleksandr-kosobokov

This comment has been minimized.

Copy link

@aleksandr-kosobokov aleksandr-kosobokov commented Feb 8, 2017

Cool

@jehrenzweig

This comment has been minimized.

Copy link

@jehrenzweig jehrenzweig commented Feb 9, 2017

You just solved a problem I've been having for months, if not years. Thank you!

@Zihad-Dmrt

This comment has been minimized.

Copy link

@Zihad-Dmrt Zihad-Dmrt commented Feb 17, 2017

How can i Remove this function after uninstall sublime text 2...... please help me

@mrchief

This comment has been minimized.

Copy link
Owner Author

@mrchief mrchief commented Mar 2, 2017

Just delete those reg entries or use a registry cleaner

@klendi

This comment has been minimized.

Copy link

@klendi klendi commented Apr 12, 2017

when i right click recycle bin it shows edit with sublime text, how to remove that and make this work only with the files?

@mittalyashu

This comment has been minimized.

Copy link

@mittalyashu mittalyashu commented Jul 17, 2017

It just works on a file. What about the folder?

What if we want to open a whole folder in sublime? ("Open as Sublime Text Project")

@mittalyashu

This comment has been minimized.

Copy link

@mittalyashu mittalyashu commented Jul 17, 2017

I somehow managed to find on internet and created a new gist.

In this gist you can create keys to open file and folders in sublime.

@ZubairKarim

This comment has been minimized.

Copy link

@ZubairKarim ZubairKarim commented Jul 23, 2017

WoW, very nice solution

@gtalarico

This comment has been minimized.

Copy link

@gtalarico gtalarico commented Sep 11, 2017

Minor Fix:

  1. Add Quotes path to allow file paths with spaces
  2. Added Option to "Open Sublime Here" to allow right clicking on directory background (
@echo off
SET st3Path=\"C:\Users\gtalarico\Dropbox\Shared\_Common\_Portable Apps\Sublime3\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 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 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

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

image

@jahidulsaeid

This comment has been minimized.

Copy link

@jahidulsaeid jahidulsaeid commented Oct 26, 2017

it's work for linux ?

@mittalyashu

This comment has been minimized.

Copy link

@mittalyashu 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.

@adarshanand123

This comment has been minimized.

Copy link

@adarshanand123 adarshanand123 commented Mar 8, 2018

Very very Thanks.I reduced my work.

@1j01

This comment has been minimized.

Copy link

@1j01 1j01 commented Jul 28, 2018

Remove / uninstall for the original script:

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

rem remove it for "all file types"
@reg delete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /f

rem remove it for folders
@reg delete "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /f
pause
@silviuvulcan

This comment has been minimized.

Copy link

@silviuvulcan silviuvulcan commented Dec 13, 2018

License?

I want to fork https://github.com/jcppkkk/OpenWithSublime to create a similar set of scripts for Visual Basic Code. Asked him about license and he pointed that his scripts are forked from https://gist.github.com/FoxColdMetal/7403764 which are forked from these. So what license would it be ? :)

@ibrahimoguzhany

This comment has been minimized.

Copy link

@ibrahimoguzhany ibrahimoguzhany commented Oct 6, 2020

I've never used Sublime Text 2 and i didn't read carefully that this post is about Sublime Text 2. I'm using Sublime Text 3 instead. So i added open with Sublime Text 2 option to the right click and don't know how to undo it. Any ideas?

I succesfully added open with sublime text 3 option by changing everything from 2 to 3 by editing the folder. You should change st2 to st3 in addition to that.

@mrchief

This comment has been minimized.

Copy link
Owner Author

@mrchief mrchief commented Oct 6, 2020

Added License. Feel free to send your st3 updates and I can add them here. I don't use ST anymore but seeing how useful this is, I want continue supporting this.

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.