快捷方式/"Open with" Sublime Text,在一个新的 Sublime window
Shortcut/"Open with" Sublime Text, in a new Sublime window
我正在寻找一种方法来右键单击 Windows 10 中的文件,select "Open with" -> "Sublime Text",然后有一个 new Sublime Text window 出现。
如果 Sublime 已经打开,默认操作是在新选项卡中打开文件。这通常不是我想要的,尤其是因为我通常在不同的桌面上打开 Sublime。
我尝试创建一个添加了 -n
标志的快捷方式,当我使用该快捷方式时,它正确地为我提供了一个新的 window。但是当我 "Open with" 使用该快捷方式时,它会在现有的 window.
中打开文件
我还尝试了 "Open with" 一个包含 subl -n
的批处理文件,``但是唉。
打开设置,然后在 { } 之间添加以下行:
"open_files_in_new_window": false
这对我有用(对我来说比打开子菜单更舒服):
- 打开
regedit.exe
- 导航到
HKEY_CLASSES_ROOT\*\shell
要仅将此应用于某些文件类型,请将 *
替换为适当的扩展名
- 添加密钥"Open With sublime in new window"
- 在里面,添加新键"command"
- 在 "command" 中将
(Default)
字符串设置为:
C:\Program Files\Sublime Text 2\sublime_text.exe -n "%1"
(基本复制原来的keys,加上-n
)
- 可选:
在键 "Open With sublime in new window" 内,添加一个名为 Icon
:
的字符串
C:\Program Files\Sublime Text 2\sublime_text.exe,0
这将在右键单击菜单上的命令左侧添加一个 Sublime Text 图标。
要将条目添加到文件夹的上下文菜单,请在以下位置添加相同的条目:
- HKEY_CLASSES_ROOT\Folder\shell
对于单击文件夹图标时的上下文菜单
- HKEY_CLASSES_ROOT\Directory\Background\shell
对于单击文件夹背景时的上下文菜单
对于此条目,您必须将 "%1"
替换为 "%V"
(感谢 Filip)
如果您更喜欢使用脚本执行此操作,请考虑在批处理脚本中使用以下内容:
@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
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" /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
rem add it for current folder
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%v\"" /f
pause
将其放入 .bat 文件(我的文件名为 SetSublimeMenuShortcuts.bat),然后 运行 在 Powershell 中作为管理员用户使用 .\SetSublimeMenuShortcuts.bat 调用它。如果您看到以下内容,则应正确设置:
The operation completed successfully.
The operation completed successfully.
The operation completed successfully.
The operation completed successfully.
The operation completed successfully.
The operation completed successfully.
Press any key to continue . . .
我正在寻找一种方法来右键单击 Windows 10 中的文件,select "Open with" -> "Sublime Text",然后有一个 new Sublime Text window 出现。
如果 Sublime 已经打开,默认操作是在新选项卡中打开文件。这通常不是我想要的,尤其是因为我通常在不同的桌面上打开 Sublime。
我尝试创建一个添加了 -n
标志的快捷方式,当我使用该快捷方式时,它正确地为我提供了一个新的 window。但是当我 "Open with" 使用该快捷方式时,它会在现有的 window.
我还尝试了 "Open with" 一个包含 subl -n
的批处理文件,``但是唉。
打开设置,然后在 { } 之间添加以下行:
"open_files_in_new_window": false
这对我有用(对我来说比打开子菜单更舒服):
- 打开
regedit.exe
- 导航到
HKEY_CLASSES_ROOT\*\shell
要仅将此应用于某些文件类型,请将*
替换为适当的扩展名 - 添加密钥"Open With sublime in new window"
- 在里面,添加新键"command"
- 在 "command" 中将
(Default)
字符串设置为:
C:\Program Files\Sublime Text 2\sublime_text.exe -n "%1"
(基本复制原来的keys,加上-n
)
- 可选:
在键 "Open With sublime in new window" 内,添加一个名为Icon
:
的字符串C:\Program Files\Sublime Text 2\sublime_text.exe,0
这将在右键单击菜单上的命令左侧添加一个 Sublime Text 图标。
要将条目添加到文件夹的上下文菜单,请在以下位置添加相同的条目:
- HKEY_CLASSES_ROOT\Folder\shell
对于单击文件夹图标时的上下文菜单 - HKEY_CLASSES_ROOT\Directory\Background\shell
对于单击文件夹背景时的上下文菜单
对于此条目,您必须将"%1"
替换为"%V"
(感谢 Filip)
如果您更喜欢使用脚本执行此操作,请考虑在批处理脚本中使用以下内容:
@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
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" /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
rem add it for current folder
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%v\"" /f
pause
将其放入 .bat 文件(我的文件名为 SetSublimeMenuShortcuts.bat),然后 运行 在 Powershell 中作为管理员用户使用 .\SetSublimeMenuShortcuts.bat 调用它。如果您看到以下内容,则应正确设置:
The operation completed successfully.
The operation completed successfully.
The operation completed successfully.
The operation completed successfully.
The operation completed successfully.
The operation completed successfully.
Press any key to continue . . .