Sublime Text 3,如何添加到右键单击?

时间:2016-10-03 20:20:20

标签: sublimetext3

如何添加Sublime Text就像使用Notepad ++编辑一样,它没什么大不过的,但它可以节省时间。

enter image description here

9 个答案:

答案 0 :(得分:37)

  1. 使用记事本创建新文本文档并将其保存在桌面上
  2. 将其重命名为OpenWithSublime.bat
  3. 把它放在里面:
  4. 
    
    @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. 以管理员身份运行
    2. 来源:https://gist.github.com/roundand/9367852

答案 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)

只需重新启动安装程序即可。

点击这里:

enter image description here

然后勾选这个选项:

enter image description here

让它完成,你现在就会拥有这个:

enter image description here

答案 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版本

  1. 创建一个sumblime.bat文件
  2. 将以下文本放入其中

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
  1. 以管理员身份运行

答案 8 :(得分:0)

您可以使用 regedit 将 sublime 文本添加到上下文菜单。为了更简单的步骤,请尝试批处理文件脚本

  1. 打开记事本并粘贴此代码

@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

  1. 将其另存为 context.bat(或 any_name.bat)并以管理员身份运行。完成

来源:Narendra Dwivedi - Add Sublime text to context