Sublime Forum

Cannot make sublime 3 default editor windows 10 (Sept 2018)

#21

I just helped a colleague with a similar issue with Notepad++.

Apparently the latest Windows build is a lot more strict about properly registering applications support for file associations. I brought up a similar issue a while ago here.

Basically, you need to add some registry settings to tell windows that Sumblime can open said files.

I have a sample registry file which adds support for:
.as, .asm, .c, .cc, .cfg, .cpp, .h, .hpp, .ini, .inl, .lua, .nfo, .txt

Before you attempt to run the file, I highly recommend you read through it and understand it. Likewise, you will probably want to add/remove supported types from the script.

Note: If sublime is not installed to C:\Program Files\Sublime Text\sublime_text.exe, you will need to modify the script
Run at your own risk: Bind Sublime File Associations.

1 Like

#22

Thanks! So this should be fixable with a Sublime update? This should probably also be mentioned in the microsoft thread linked above.

Care to explain what each line does? I see the 5 repeating ones for each extension:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SublimeText.txt]
@="Text File"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SublimeText.txt\DefaultIcon]
@="\"%SystemRoot%\\system32\\imageres.dll\",-102"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SublimeText.txt\shell]
@="Open"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SublimeText.txt\shell\Open]
@="Edit"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SublimeText.txt\shell\Open\command]
@="\"C:\\Program Files\\Sublime Text\\sublime_text.exe\" \"%1\""

And this bit at the bottom:

[HKEY_LOCAL_MACHINE\SOFTWARE\Sublime\SublimeText\Capabilites]
"ApplicationDescription"="Sublime Text 3 - Text editor of the future!"
"ApplicationName"="Sublime Text 3"
"ApplicationIcon"="\"C:\\Program Files\\Sublime Text\\sublime_text.exe\",0"

[HKEY_LOCAL_MACHINE\SOFTWARE\Sublime\SublimeText\Capabilites\FileAssociations]
".as"="SublimeText.as"
...
".txt"="SublimeText.txt"

[HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications]
"Sublime Text 3"="Software\\Sublime\\SublimeText\\Capabilites"

I just think it’d be really difficult/time-consuming for me to look this up to understand it but really easy for you to explain.

And specifically, what does that DefaultIcon look like?

Edit: Can confirm this script solved it on my PC. Had to find and replace C:\\Program Files\\Sublime Text\\ to C:\\Program Files\\Sublime Text 3\\, after which it worked.

By the way, for whoever wants to know, icons look like this:

It’s probably be better/nicer to use the Sublime icon, "C:\Program Files\Sublime Text 3\sublime_text.exe",0

0 Likes

#23

For each file type, you can define a type handler:

; Create a new file type handler class and give it a description
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SublimeText.txt]
@="Text File"

; Define the Icon to use for the file
; Note: This is optional. If not defined, the program icon will be used
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SublimeText.txt\DefaultIcon]
@="\"%SystemRoot%\\system32\\imageres.dll\",-102"

; Define the default shell action (what to trigger when double clicked)
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SublimeText.txt\shell]
@="Open" 

; Declare the default action defined above (Open) and assign some text to the command
; Note: The text below (Edit) will be shown at the top of the right click menu for that type
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SublimeText.txt\shell\Open]
@="Edit"

; Define the command for the "Open" action
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SublimeText.txt\shell\Open\command]
@="\"C:\\Program Files\\Sublime Text\\sublime_text.exe\" \"%1\""

Technically, if you don’t care about the file description or assigning custom icons to each file type, you can really just declare one file type handler. You should just need to replace “SublimeText.txt” with something like “SublimeTextDoc” and assign default values for everything.

The second section defines basic display information for the application:

[HKEY_LOCAL_MACHINE\SOFTWARE\Sublime\SublimeText\Capabilites]
; Give the application a description
; This use to be view-able in the Control Panel, but I think it's no longer shown
"ApplicationDescription"="Sublime Text 3 - Text editor of the future!"

; Give a readable name to the program
; Shown in several places (Open with menu and such)
"ApplicationName"="Sublime Text 3"

; Icon to show for the program, generally next to the name (Open with menu and such)
"ApplicationIcon"="\"C:\\Program Files\\Sublime Text\\sublime_text.exe\",0"

The third section defines the file types the applications supports, and the handler to use:

[HKEY_LOCAL_MACHINE\SOFTWARE\Sublime\SublimeText\Capabilites\FileAssociations]
; Format: <File Type>=<File Handler>
".as"="SublimeText.as"
...
".txt"="SublimeText.txt"

So, if you created a generic “SublimeTextDoc” handler class, and you wanted sublime to open python files, you would add something like:

".py"="SublimeTextDoc"

Similarly, if you create a specific handler with a custom icon, you would replace SublimeTextDoc with your custom handler (SublimeText.py if you followed my pattern)

The final section tells Windows where you find the program information. This effectively adds Sublime to the “Open With” menu and such.

[HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications]
"Sublime Text 3"="Software\\Sublime\\SublimeText\\Capabilites"

As a side note, the “DefaultIcon” from the sample reg file isn’t what I actually use. I generally use a bunch of icons provided by Visual Studio, which looks like a basic white rect with the extension overlayed. Since everyone doesn’t have VS, I replaced the custom icon with more generic stuff.

3 Likes

#24

Shouldn’t ApplicationDescription and ApplicationName be defined already? (no way to check now, I already ran the script…)

Regarding the icons, I’d personally avoid VS icons since I want to know which program is going to open before I double-click if I happen upon a file type I didn’t assign before.

Anyway, thanks a lot!

0 Likes

#25

I generally use the portable version of sublime, which doesn’t write anything to the registry.

The Installer might, but I havn’t run that in ages. I think it doesn’t write anything to the registry, but I’m not sure.

0 Likes

#26

This doesn’t work on a new Surface Go with Win 10 Pro and latest installed (not portable) x64 version of Sublime 3

0 Likes

#27

Hi, guys! I have the same problem. Sorry, i not well in English, if i undertsand correct — you have not find solution to fix this, right? And what now? Wait for new sublime or win10 updates?

0 Likes

#29

I have solved partically issue for myself, because I need just one time assign what extension will be used and opened in Sublime Text.

How have I solved the problem (Microsoft bug)

Please follow all steps, otherwise it will not work.

  1. Double click on file what you wish to open, if it opened in the default edit, just close it, and right click -> open with
  2. In Open With find sublime text editor and select it.
  3. Will be opened the file in the Sublime Text, now just close the Sublime Text with the file. This is very important to launch an APP with file
  4. Now right click -> Properties -> Change
  5. Select Sublime Text
  6. Apply - Ok
  7. As you see now it works, and extension works fine.

In any other method the problem will not be resolved, only with this order
(you must to run for some reason a file what you wish to change “open with” to different app at least once in the app what you wish to re-assign before trying to pressing “change” button in properties".

This is super awful and ugly, but it works.

0 Likes

#30

Unfortunately, this method also doesn’t work (on me PC, at least). System have no react, when i try to change. http://joxi.ru/LmGev3LUwexLEA (sorry, Russian letters). Then i click «ok» and nothing changes =/

For example .html files — i can change browser in «properties» and it’s ok. But if i try another app (not only sublime, also notepad, for example) system just ignore me.

0 Likes

#31

Yes, because you need follow like it’s wrote above.
Again:

  1. You need open with Sublime Text a file first from “Open With” Windows feature any file what you wish to re-assign to Sublime Text.
  2. Only then you will be able after opening “open with” you will be able to switch the extension.
0 Likes

#32

doesn’t work

0 Likes

#33

Of course i did it, you have wrote twice about it :slight_smile: anyway, no results

0 Likes

#34

Looks like the latest Windows update KB4467682 fixes this issue:

Addresses an issue that prevents some users from setting Win32 program defaults for certain app and file type combinations using the Open with… command or Settings > Apps > Default apps.

Can confirm, it worked.

1 Like

#35

I wonder why nobody mentioned they were using 32 bit ST seeing as its an odd choice

1 Like

#36

Hooray, the problem has gone with latest windows updates!

0 Likes

#37

I use 64-bit

0 Likes

#38

It’s the 64-bit version too. Windows terminology is a bit silly, but I think “Win32” refers in this case to any application not from the Microsoft Store.

0 Likes

#39

After manually update KB44676828, is working now

Edition: Windows 10 Enterprise
Version: 1803
OS build: 17134.441

0 Likes

#40

I worked around this by right clicking on a .txt and using the open with option to select sublime and checking to always use this applicaiton.

0 Likes