Windows中將Sublime text加入右鍵選單的方法

身為Sublime Text的重度使用者。
之前已經有把Sublime text加入Windows的右鍵選單裡面了,
不過不知道是因為甚麼東西更新,所以又消失了。
今天重新設定了,順便筆記一下。

方法很簡單
新增以下的腳本 opensublime.bat
名稱隨便取,只要副檔名是bat就好

然後內容如下
其中只要注意st3Path後面的路徑是你的sublime_text.exe安裝路徑就好
然後用管理員執行bat腳本就搞定了

@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

改完之後,右鍵就可以按到利用Sublime Text開啟的選項了

其實看內容也可以看得出來是去修改registry
按下Win+R輸入regedit也可以從圖形化介面去設定

上面腳本分成了三段加入
第一段是針對檔案點右鍵
第二段是針對資料夾點右鍵
第三段是針對背景點右鍵

發佈留言