41

How do I add Sublime Text just like how Edit with Notepad++ is there it's nothing big but it saves time.

enter image description here

9 Answers 9

92
  1. Create a new text document with notepad and save it on your desktop
  2. Rename it to OpenWithSublime.bat
  3. Put this inside:

@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

rem add it for right click on explorer
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Sublime"         /t REG_SZ /v "" /d "Open with Sublime Text 3"   /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Sublime"         /t REG_SZ /v "Icon" /d "%st3Path%" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Sublime\command" /t REG_SZ /v "" /d "%st3Path% \"%%V\"" /f
pause

  1. Run it as Administrator

Source: https://gist.github.com/roundand/9367852

3
  • Love running batch scripts so I was able to modify this and added a few other options. It works great for me
    – Hill
    Jul 14, 2017 at 17:20
  • Right click the empty area of explorer does not show the context menu in this way. You need to add [HKEY_CLASSES_ROOT\Directory\Background\shell\Sublime] too. Jun 1, 2019 at 3:08
  • There is an easier way: stackoverflow.com/a/66662987/1559036 Mar 16, 2021 at 20:33
25

Just create a reg file subl.reg and open it with a text editor and add the content:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text]
@="Edit with &Sublime Text"
"Icon"="C:\\Program Files\\Sublime Text 3\\sublime_text.exe,0"
"MuiVerb"="Edit with Sublime Text"

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

[HKEY_CLASSES_ROOT\Directory\Background\shell\Sublime]
@="Open with Sublime Text"
"Icon"="C:\\Program Files\\Sublime Text 3\\sublime_text.exe,0"

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

[HKEY_CLASSES_ROOT\Directory\shell\Sublime]
@="Open with Sublime Text"
"Icon"="C:\\Program Files\\Sublime Text 3\\sublime_text.exe,0"

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

You may need to adapt the paths to your Sublime Text installation. This will add Sublime Text when you rightlick on a file, rightlick on a folder background, and rightclick on a folder. Just double click on the file to add the entries into your registry.

You can always edit and delete those entry by pressing window+r and then write regedit in that panel. There you will see the same path structure, e.g. HKEY_CLASSES_ROOT\*\shell for right click commands.

2
  • 3
    Beautiful. For people who don't know what to do with the .reg file, just open it after you're done editing. Mar 22, 2018 at 8:30
  • Amazing, for those who are having a hard time at opening the .reg file with admin permission just save the file, open regedit as admin and go to File>Import
    – brodegon
    May 27, 2021 at 9:33
15

You can click a checkbox labelled Add to explorer context menu when installing Sublime Text.

If that does not work; here is a thread that goes in depth into how to achieve this: https://sublimetext.userecho.com/topics/3947-windows-context-menu-right-click-edit-with-sublime-notepad-style/

1
5

Thanks r-stein for the above answer. But [HKEY_CLASSES_ROOT\Directory\shell\Sublime\command] have some problems. the last argument should \"%V\"" instead \"%1\"".

The full subl.reg is

Windows Registry Editor Version 5.00

; show in context menu when right click all kinds files
[HKEY_CLASSES_ROOT\*\shell\Sublime]
@="Open with Sublime Text 3"
"Icon"="C:\\Program Files\\Sublime Text 3\\sublime_text.exe,0"

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

; show in context menu when right click empty area of explorer
[HKEY_CLASSES_ROOT\Directory\Background\shell\Sublime]
@="Open with Sublime Text 3"
"Icon"="C:\\Program Files\\Sublime Text 3\\sublime_text.exe,0"

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

; show in context menu when right click directory
[HKEY_CLASSES_ROOT\Directory\shell\Sublime]
@="Open with Sublime Text 3"
"Icon"="C:\\Program Files\\Sublime Text 3\\sublime_text.exe,0"

[HKEY_CLASSES_ROOT\Directory\shell\Sublime\command]
@="\"C:\\Program Files\\Sublime Text 3\\sublime_text.exe\" \"%V\""
0
4

Just re-launch the installer.

Click this:

enter image description here

then check this option:

enter image description here

Let it finish and you'll now have this:

enter image description here

2
  • The easiest solution without getting into the intricacies. Feb 23, 2022 at 13:05
  • What if you don't have the installer? I.e. I installed the portable version
    – NotAPro
    Apr 19, 2022 at 11:20
2

Create sublime_contextmenu.bat file in sublime_text folder and put the following contents.

@echo off

SET APP_PATH=%~dp0sublime_text.exe
echo %APP_PATH%

echo Add it for all file types
reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3"         /ve /d "Open with Sublime Text 3"   /f
reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3"         /v "Icon" /d "\"%APP_PATH%\"" /f
reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /ve /d "\"%APP_PATH%\" \"%%1\"" /f

echo Add it for folders
reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3"         /ve /d "Open with Sublime Text 3"   /f
reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3"         /v "Icon" /d "\"%APP_PATH%\"" /f
reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3\command" /ve /d "\"%APP_PATH%\" \"%%1\"" /f
pause

Run as administrator.

1

The perfect one for Windows

  1. create a sumblime.bat file
  2. put the following text into it

sublime.bat

@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_EXPAND_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_EXPAND_SZ /v "" /d "%st3Path% \"%%1\"" /f
 
rem add it for right click on explorer
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text 3"         /t REG_EXPAND_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%" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text 3\command" /t REG_EXPAND_SZ /v "" /d "%st3Path% \"%%V\"" /f 

rem add it for right click on explorer
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3"         /t REG_EXPAND_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%" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3\command" /t REG_EXPAND_SZ /v "" /d "%st3Path% \"%%V\"" /f
pause
  1. Run it as Administrator
0

You can add sublime text to context menu by using regedit . For more easy step , try batch file script

  1. Open notepad and paste this code

@echo off
title Add SublimeText To Context Menu
set/p installedpath=Enter SublimeText Installed Path : 
set/p contexttext=Enter Context Menu Text : 
SET STPath=%installedpath%\sublime_text.exe
@reg add "HKEY_CLASSES_ROOT\*\shell\%contexttext%"
@reg add "HKEY_CLASSES_ROOT\*\shell\%contexttext%"         /t REG_SZ /v "Icon" /d "%STPath%" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\%contexttext%\command" /t REG_SZ /v "" /d "%STPath% \"%%1\"" /f
goto done
:done
echo Added To Context Menu
pause

  1. Save it as context.bat (or any_name.bat) and run as admin. Done

Source : Narendra Dwivedi - Add Sublime text to context

-1

UPDATE May 2018: No longer available, package has been removed.


If you have chocolatey, you could just run:

choco install sublimetext3-contextmenu
2
  • 2019 and this works for me. None of the answers mention a package..?? I used the registry modification answer.
    – Samuel
    Apr 19, 2019 at 21:59
  • 1
    I tried, but it gave the following errors, sublimetext3-contextmenu not installed. The package was not found with the source(s) listed. Source(s): 'chocolatey.org/api/v2' NOTE: When you specify explicit sources, it overrides default sources. If the package version is a prerelease and you didn't specify --pre, the package may not be found. Please see chocolatey.org/docs/troubleshooting for more assistance. Jun 1, 2019 at 2:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.