【发布时间】:2017-02-11 21:06:44
【问题描述】:
【问题讨论】:
标签: sublimetext3
【问题讨论】:
标签: sublimetext3
@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
【讨论】:
[HKEY_CLASSES_ROOT\Directory\Background\shell\Sublime]。
只需创建一个 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 用于右键单击命令。
【讨论】:
在安装 Sublime Text 时,您可以单击标记为 添加到资源管理器上下文菜单 的复选框。
如果这不起作用;这是一个深入探讨如何实现这一点的线程:https://sublimetext.userecho.com/topics/3947-windows-context-menu-right-click-edit-with-sublime-notepad-style/
【讨论】:
感谢 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\""
【讨论】:
在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
以管理员身份运行。
【讨论】:
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
【讨论】:
您可以使用 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
【讨论】:
2018 年 5 月更新:不再可用,软件包已被删除。
如果你有巧克力,你可以跑:
choco install sublimetext3-contextmenu
【讨论】:
--pre,则可能找不到该软件包。如需更多帮助,请参阅chocolatey.org/docs/troubleshooting。