windows Sublime 作为默认编辑器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9450895/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sublime as default editor
提问by doque
Is there a way to set Sublime Text as the default text editor for file formats on Windows 7?
有没有办法将 Sublime Text 设置为 Windows 7 上文件格式的默认文本编辑器?
Also, if anyone knew a Sublime Text Tutorial or Wiki that would be really helpful.
此外,如果有人知道 Sublime Text 教程或 Wiki,那将非常有帮助。
回答by avp
Actually it is not my answer, I have just googled it:
其实这不是我的答案,我刚刚在谷歌上搜索了它:
- Open regedit (Win+R, type "regedit", select OK).
- Navigate to
HKEY_CLASSES_ROOT\Applications\sublime_text.exe\shell\open\command
- Verify that the path is accurate, correct it if it is not. Exit regedit.
- Open task manager via Ctrl+Alt+Del(or Ctrl+Shift+Escfor later versions of Windows), kill explorer.exe, go to run (Win+R) and type "explorer.exe" (or skip this step and simply reboot).
- Now attempt the same thing, right click a text file, open with, navigate to sublime, and it should now appear in the list of available applications.
- 打开 regedit(Win+ R,输入“regedit”,选择 OK)。
- 导航
HKEY_CLASSES_ROOT\Applications\sublime_text.exe\shell\open\command
- 验证路径是否准确,如果不正确,请更正。退出注册表。
- 通过Ctrl+ Alt+ Del(或Ctrl+ Shift+Esc用于更高版本的 Windows)打开任务管理器,杀死 explorer.exe,转到运行 ( Win+ R) 并键入“explorer.exe”(或跳过此步骤并重新启动)。
- 现在尝试同样的事情,右键单击一个文本文件,打开方式,导航到 sublime,它现在应该出现在可用应用程序列表中。
For me that value pointed to the Desktop where portable version previously was placed. Thus it just didn't work.
对我来说,该值指向以前放置便携式版本的桌面。因此它只是不起作用。
P.S. And for me the reboot or logout were not necessary (WinXP).
PS 而对我来说,不需要重新启动或注销(WinXP)。
回答by Jay Zhu
Edit on Nov 21, 2014
2014 年 11 月 21 日编辑
Tim Lewispointed out in the comment that there is a more generic version at http://www.binaryfortress.com/NotepadReplacer/, which works better.
Tim Lewis在评论中指出http://www.binaryfortress.com/NotepadReplacer/有一个更通用的版本,效果更好。
Original Answer
原答案
Try this: https://github.com/grumpydev/Sublime-Notepad-Replacement
试试这个:https: //github.com/grumpydev/Sublime-Notepad-Replacement
回答by robertcollier4
Here are some ways to associate Sublime Text Portable. The following text needs to be saved as a file with a .reg extension and then on that file Right Click > Merge.
以下是一些关联 Sublime Text Portable 的方法。以下文本需要保存为扩展名为 .reg 的文件,然后在该文件上右键单击 > 合并。
This will add a Sublime right click menu entry to all files:
这将为所有文件添加一个 Sublime 右键单击菜单项:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell]
@="Sublime"
[HKEY_CLASSES_ROOT\*\shell\Sublime]
@="&Sublime"
[HKEY_CLASSES_ROOT\*\shell\Sublime\command]
@="\"D:\PortableApps\SublimeText\sublime_text.exe\" \"%1\""
This will have Sublime Text replace all calls to notepad.exe:
这将使 Sublime Text 替换所有对 notepad.exe 的调用:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\Notepad.exe]
"Debugger"="\"D:\PortableApps\SublimeText\sublime_text.exe\" -z"
This will create a SublimeFile class which you can then associate with any extension.
这将创建一个 SublimeFile 类,然后您可以将其与任何扩展关联。
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\SublimeFile\shell]
@="edit"
[HKEY_CLASSES_ROOT\SublimeFile\DefaultIcon]
@="\"D:\PortableApps\SublimeText\sublime_text.exe\",0"
[HKEY_CLASSES_ROOT\SublimeFile\shell\edit\command]
@="\"D:\PortableApps\SublimeText\sublime_text.exe\" \"%1\""
This will then associate the .ext extension with SublimeFile:
这会将 .ext 扩展名与 SublimeFile 相关联:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.ext]
@="SublimeFile"
回答by Dariusz Wo?niak
1: You can also set your associations in Control Panel:
1:您还可以在控制面板中设置关联:
Control Panel > Default Programs> Associate a file or protocol with a specific program:
控制面板 >默认程序> 将文件或协议与特定程序关联:
2: Or, call it from code via IApplicationAssociationRegistrationUI::LaunchAdvancedAssociationUI
;)
2: 或者,通过代码调用它IApplicationAssociationRegistrationUI::LaunchAdvancedAssociationUI
;)
HRESULT LaunchAdvancedAssociationUI(
[in] LPCWSTR pszAppRegName
);
回答by kick3rzzz
You can just run CCleaner's registry cleaner tool and then choose and add the default program as usual. It worked for me when upgrading from ST2 to ST3.
您可以运行 CCleaner 的注册表清理工具,然后像往常一样选择并添加默认程序。从 ST2 升级到 ST3 时它对我有用。
回答by Andrey Starodubtsev
Open context menu on file with desired extension in Explorer, than select Open with->You editor ( may be you need to browse for its binary before it appears in the list of available programs ) and set checkbox "Always use the selected program to open this kind of file".
在资源管理器中打开具有所需扩展名的文件的上下文菜单,然后选择打开方式->您的编辑器(您可能需要在它出现在可用程序列表中之前浏览它的二进制文件)并设置复选框“始终使用所选程序打开这种文件”。
回答by Bassem Shahin
I tried all options to make sublime text 3 as the default program for my .php, .css and/or .js files I don't exactly know why it all failed, I think it is related to windows 10 current version bug
我尝试了所有选项使 sublime text 3 作为我的 .php、.css 和/或 .js 文件的默认程序我不完全知道为什么它都失败了,我认为它与 windows 10 当前版本的错误有关
But the good news is there is some working way for me, also for those who love CMD
但好消息是我有一些工作方式,也适用于那些喜欢 CMD 的人
- open CMD as administrator
- run this line:
FTYPE sublime="C:\Program Files\Sublime Text 3\sublime_text.exe" "%1"
- for .php files use this command:
ASSOC .php=sublime
for js use this:ASSOC .js=sublime
and so on...
- 以管理员身份打开CMD
- 运行这一行:
FTYPE sublime="C:\Program Files\Sublime Text 3\sublime_text.exe" "%1"
- 对于 .php 文件使用这个命令:
ASSOC .php=sublime
对于 js 使用这个:ASSOC .js=sublime
等等......
回答by Ijas Ameenudeen
Try this,
尝试这个,
@echo off
SET st2Path=C:\Program Files\Sublime Text 2\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
pause
I tested this for SublimeText 3(Portable) also and working fine. Create a .bat file with the above code and run it as administrator.
我也为 SublimeText 3(Portable) 测试了这个并且工作正常。使用上述代码创建一个 .bat 文件并以管理员身份运行它。
Reference : https://gist.github.com/mrchief/5628677
回答by Leonardo Mezavilla
I was facing the same problem. the only solution was correct it manually --> open regedit and navigate to Computer\HKEY_CLASSES_ROOT\Applications\, find the sublime_text.exe entry, and delete it. You should now be able to set Sublime Text 3 as the default editor for anything you want.
我面临着同样的问题。唯一的解决方案是手动更正它 --> 打开 regedit 并导航到 Computer\HKEY_CLASSES_ROOT\Applications\,找到 sublime_text.exe 条目,然后将其删除。您现在应该能够将 Sublime Text 3 设置为您想要的任何内容的默认编辑器。
i found this solution in this post:https://forum.sublimetext.com/t/cant-make-default-editor-in-windows/10747/14
我在这篇文章中找到了这个解决方案:https: //forum.sublimetext.com/t/cant-make-default-editor-in-windows/10747/14
回答by nnnn
If you are using the portable version, you can't set Sublime as the default program for any files because Windows won't acknowledge it as a program that can open things.
如果您使用的是便携式版本,则不能将 Sublime 设置为任何文件的默认程序,因为 Windows 不会将其确认为可以打开内容的程序。