Sublime Text 3 on Right Click

How To Add Open with Sublime Text 3 On Context Menu

Posted on

Sublime Text 3 is a useful tool either for development or just edit a file. This tutorial will guide you to enable Sublime Text 3 on context menu / when right click on file.

Let’s get started.

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

4. Run it with Administrator privileges.

Result:

Open with Sublime Text 3 when Right Click on file

Done.

References:

https://stackoverflow.com/questions/39839764/sublime-text-3-how-to-add-to-right-click

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

Leave a Reply

Your email address will not be published. Required fields are marked *