Open with sublime text windows

Add «Open with Sublime Text 3» to Windows Explorer Context Menu (including folders)


This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters

Show hidden characters

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

It’s a great code editor. It can be an IDE if you want it to be, but at it’s heart it’s a highly extensible text editor. But still it lacks behind one important feature to open project in Sublime Text from menus.

Sublime Text, by default, will give you the option to add Open with Sublime Text to the context menu when right-clicking any file. This is great and I use it a lot, make sure you’ve selected it during the install before starting this.

Open as Sublime Project

One thing that I have trouble with is that I do have other context menu enhancements and the Open with Sublime Text doesn’t always jump out at me. So one thing we’re going to do is add the Sublime Text icon to the existing context menu option. The other thing we’re going to do is add an Open Directory with Sublime Text action to the context menu when we right-click on a directory. All it takes is creating a .reg file to update your registry.

1. Create a file on your desktop

  1. Right-click on the desktop
  2. Click New > Text Document
  3. Name it “SublimeContext.reg” make sure to drop the .txt extension

2. Open in Notepad (or Sublime Text)

  1. Make note of your installation directory of Sublime Text. I’m running Windows 8.1 with Sublime Text 3 in the default location. so for me, it is C:\Program Files\Sublime Text 3\sublime_text.exe
  2. If your’s is the same, no need to do anything, otherwise you’ll have to edit the block below with your default installation.
  3. Copy and paste the following block into your file.
    «`
    Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT*\shell\Open with Sublime Text]
“Icon”=”C:\Program Files\Sublime Text 3\sublime_text.exe”
[HKEY_CLASSES_ROOT*\shell\Open with Sublime Text\command]
@=”C:\Program Files\Sublime Text 3\sublime_text.exe «%1″”

[HKEY_CLASSES_ROOT\Directory\Background\shell\Sublime Text]
@=”Open Directory with Sublime Text”
“Icon”=”C:\Program Files\Sublime Text 3\sublime_text.exe”
[HKEY_CLASSES_ROOT\Directory\Background\shell\Sublime Text\command]
@=”C:\Program Files\Sublime Text 3\sublime_text.exe «%V»”

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Sublime Text]
@=”Open Directory with Sublime Text”
“Icon”=”C:\Program Files\Sublime Text 3\sublime_text.exe”
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Sublime Text\command]
@=”C:\Program Files\Sublime Text 3\sublime_text.exe «%V»”

4. Save and close your file.
5. Double-click on it and say yes, you want to add it to the registry.

## What's it doing?

I know I'm suspicious of modifying the registry, so let's walk through each line.

***

[HKEY_CLASSES_ROOT*\shell\Open with Sublime Text]
“Icon”=”C:\Program Files\Sublime Text 3\sublime_text.exe”
[HKEY_CLASSES_ROOT*\shell\Open with Sublime Text\command]
@=”C:\Program Files\Sublime Text 3\sublime_text.exe «%1″”


These two are merely updating an existing key. The first `HKEY` is ensuring that you have the *Open with Sublime Text* context menu. The `Icon String Value` is a new one we're adding. It's simply adding the Sublime Text icon to the context menu. The second `HKEY` was an existing key that executes the command of opening the file you right-click in Sublime Text.

***

[HKEY_CLASSES_ROOT\Directory\Background\shell\Sublime Text]
@=”Open Directory with Sublime Text”
“Icon”=”C:\Program Files\Sublime Text 3\sublime_text.exe”
[HKEY_CLASSES_ROOT\Directory\Background\shell\Sublime Text\command]
@=”C:\Program Files\Sublime Text 3\sublime_text.exe «%V»”


These two add the new Open Directory with Sublime Text to the background context menu, we'll cover each line specifically below which adds to the right-click context menu in the same way.

***

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Sublime Text]
@=”Open Directory with Sublime Text”
“Icon”=”C:\Program Files\Sublime Text 3\sublime_text.exe”
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Sublime Text\command]
@=”C:\Program Files\Sublime Text 3\sublime_text.exe «%V»”
«`

These two are completely new. This is what adds Open Directory with Sublime Text to the right-click context menu. The first HKEY adds the text to the context menu and the Icon. The second HKEY adds the command of opening the directory you right-clicked in Sublime Text.

It’s not much, but it adds a nice little touch to an amazing product. Have fun with it!

Skip to content

How to add a Open with SublimText option in Windows 10 manually ,using Windows Registry

SublimText editor is one of the coolest code editor I found, it is Mac favorite. When we install the software it as let us choose open with option, which let us open file with Sublim. How to configure this manually?

I found VS Code already included to the context menu. Let’s add the option to context menu using Windows Registry. (What is a Registry ? It keep track all the members(apps,settings etc) of the Windows).

This involves following step

  • Open Windows Registry
  • Find *\shell
  • Create new Key,value

Create New Keys,Value

Login as Admin and open Run dialog using Windows + R . Enter regedit in the Run windows. We have to find the */Shell key. The easiest way to do is type the following lines below the File menu.

Computer\HKEY_CLASSES_ROOT*\shell\

Under the shell we have to create one new key and value with a command sub key as follows.

Open with Sublime Text
  • Create another Key under the Sublim Tex as command
  • Modify the command default value on the right panel as C:\Program Files\Sublime Text 3\sublime_text.exe “%1”

Now you can open a file in Sublim using the context menu.

* Please do all these with care. Don’t attempt to change any system related entries

This batch script will add the option to open any file or folder with Sublime Text 3 to the context menu in Windows Explorer.

Alternative 1: Batch file

Just replace the path C:\Portable\sublimetext\sublime_text.exe with the path to your sublime_text.exe, save the script as a .bat file and run the script once.

@Echo OFF
SET path=C:\portable\sublimetext\sublime_text.exe
REG ADD "HKCR\*\shell\Open with Sublime Text 3" /V "" /D "Open with Sublime Text 3" /F 1>NUL
REG ADD "HKCR\*\shell\Open with Sublime Text" /V "Icon" /T "REG_EXPAND_SZ" /D "%path%,0" /F 1>NUL
REG ADD "HKCR\*\shell\Open with Sublime Text\command" /V "" /D "%path% \"%%1\"" /F 1>NUL
REG ADD "HKCR\Folder\shell\Open with Sublime Text" /V "" /D "Open with Sublime Text" /F 1>NUL
REG ADD "HKCR\Folder\shell\Open with Sublime Text" /V "Icon" /T "REG_EXPAND_SZ" /D "%path%,0" /F 1>NUL
REG ADD "HKCR\Folder\shell\Open with Sublime Text\command" /V "" /D "%path% \"%%1\"" /F 1>NUL
Add Sublime Text to context menu in Windows 10 illustration

Sublime Text 3 in Windows 10 context menu

Alternative 2: Command Prompt

Note that if you want to run this script directly in the command prompt (without a batch file) you will have to replace the double percentage signs with a single percentage. Like this:

SET path=X:\portable\sublimetext\sublime_text.exe
REG ADD "HKCR\*\shell\Open with Sublime Text" /V "" /D "Open with Sublime Text" /F 1>NUL
REG ADD "HKCR\*\shell\Open with Sublime Text" /V "" /D "Open with Sublime Text" /F 1>NUL
REG ADD "HKCR\*\shell\Open with Sublime Text" /V "Icon" /T "REG_EXPAND_SZ" /D "%path%,0" /F 1>NUL
REG ADD "HKCR\*\shell\Open with Sublime Text\command" /V "" /D "%path% \"%1\"" /F 1>NUL
REG ADD "HKCR\Folder\shell\Open with Sublime Text" /V "" /D "Open with Sublime Text" /F 1>NUL
REG ADD "HKCR\Folder\shell\Open with Sublime Text" /V "Icon" /T "REG_EXPAND_SZ" /D "%path%,0" /F 1>NUL
REG ADD "HKCR\Folder\shell\Open with Sublime Text\command" /V "" /D "%path% \"%1\"" /F 1>NUL

Set Sublime Text as the default text editor

You can use Notepad Replacer to set Sublime Text 3 as the default text editor software in Windows.

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Не работает альт шифт windows 10 для переключения языка
  • Как в dell зайти в безопасный режим windows
  • Изменить тип сети windows 10 реестр
  • Изменение автозагрузки в windows 7
  • Как настроить значки рабочего стола в windows 10