答案 0 :(得分:37)
@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

答案 1 :(得分:17)
只需创建一个reg文件subl.reg
并使用文本编辑器打开它并添加内容:
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\""
您可能需要调整Sublime Text安装的路径。当您右键单击文件时,这将添加Sublime Text,右键单击文件夹背景,然后右键单击文件夹。 只需双击该文件即可将条目添加到注册表中。
您可以随时按window+r
编辑和删除这些条目,然后在该面板中写下regedit
。你会看到相同的路径结构,例如HKEY_CLASSES_ROOT\*\shell
用于右击命令。
答案 2 :(得分:6)
显然,您可以点击一个复选框"添加到资源管理器上下文菜单"安装sublime文本时。如果这不起作用,这里有一个似乎深入探讨如何实现这一目标的主题:https://sublimetext.userecho.com/topics/3947-windows-context-menu-right-click-edit-with-sublime-notepad-style/
答案 3 :(得分:1)
在 sublime_text文件夹中创建 sublime_contextmenu.bat 文件,然后放入以下内容。
@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
以管理员身份运行。
答案 4 :(得分:1)
答案 5 :(得分:0)
2018年5月更新:不再可用,套餐已被删除。
如果你有巧克力,你可以运行:
choco install sublimetext3-contextmenu
答案 6 :(得分:0)
感谢r-stein提供上述答案。但是[HKEY_CLASSES_ROOT\Directory\shell\Sublime\command]
有一些问题。最后一个参数应为\"%V\""
而不是\"%1\""
。
完整的subl.reg
是
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\""
答案 7 :(得分:0)
完美的Windows版本
sumblime.bat
文件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
答案 8 :(得分:0)
您可以使用 regedit 将 sublime 文本添加到上下文菜单。为了更简单的步骤,请尝试批处理文件脚本
@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