Add Sublime Text to your context menu on right click

  sonic0002        2015-10-19 08:51:25       27,182        9         

When opening a text file, you may be used to right click on the file to be opened and then choose the application which can open the file from the context menu. On the context menu, you may see a menu item like "Edit with Notepad++".

Nowadays many people especially programmers like to use Sublime Text, but by default this application will not show on the context menu when you right click on a file. There is now frequent request to add this application to the context menu. Here we show a simple batch file which can help you achieve this.

Below is the batch code :

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

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

pause

You just need to copy above code into the text editor you like and save it as a batch file. Note, please change the sublimeTextPath to the sublime_text.exe on your system. Then, what you need to do is right click on the batch file you saved and "Run as administrator" and it should show below:

This means you have successfully added Sublime Text to your context menu. Then you can verify this by right clicking on any text file and you should see below:

Please note that you need to run the batch file as administrator, otherwise you will see errors on the command line console.

WINDOWS  SUBLIME TEXT  CONTEXT MENU 

           

  RELATED


  9 COMMENTS


Simon Suh
Oct 2, 2016 at 3:41 pm

Thanks, this helped me add the option to the control menu.

DevChic
Jan 18, 2017 at 1:40 am

Thanks! It works :)

Anonymous
Oct 2, 2017 at 3:38 am

123132131

nnyms
Oct 2, 2017 at 3:39 am

im gonna swing like a chandelier 

Anonymous
Apr 4, 2019 at 6:57 am

Make a .bat file, don't run in cmd because it will not work

Anonymous
Feb 20, 2021 at 10:14 am

thanks for tip, ran this as .cmd and it didn't work (it was in context menu, but was throwing an error when clicked)

running in .bat fixed this issue

Haena
Feb 21, 2020 at 7:40 am

Hi thank you for this tutorial. can you show me how to undo this please ? 
I already have this option on my context menu and now, i have two "open with sublime text" lol 
actually what i was looking for is how make "open a new text file" load using sublime text by default. 

Ke Pi
Feb 21, 2021 at 3:35 am

Hi, Haena,

You can use below command to delete:

@reg delete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3"         /f
Anonymous
May 30, 2022 at 4:32 am

Or you can use this, which supports Sublime Text 4 too:

 

Sublime Text right click context menu and PATH variable setup (Windows) (github.com)



  RANDOM FUN

Usain Bolt : Oh no!

Usain Bolt won the 200m short run gold medal in Beijing.  When he wlked off the track, he was suddenly hit by a camera man. Oh, no. This should be seen on a football court only.

  SUPPORT US