Add Sublime Text to your context menu on right click

  sonic0002        2015-10-19 08:51:25       26,797        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 [Reply]@ 2016-10-02 15:41:03

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

DevChic [Reply]@ 2017-01-18 01:40:35

Thanks! It works :)

Anonymous [Reply]@ 2017-10-02 03:38:21

123132131

nnyms [Reply]@ 2017-10-02 03:39:45

im gonna swing like a chandelier 

Anonymous [Reply]@ 2019-04-04 06:57:50

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

Anonymous [Reply]@ 2021-02-20 10:14:01

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 [Reply]@ 2020-02-21 07:40:24

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 [Reply]@ 2021-02-21 03:35:26

Hi, Haena,

You can use below command to delete:

@reg delete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3"         /f
Anonymous [Reply]@ 2022-05-30 04:32:12

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

End user perspective