Sublime Forum

Windows: Can't set SB3 as default text editor

#1

I go to

Open With > Choose Default Program > Browse > C:\Program Files (x86)\Sublime Text 3\sublime_text.exe > Open

but Sublime Text does not appear on the menu, so I have to select of the others as the default, then click OK.

0 Likes

#2

If you can’t find the app on the list, there is usually a “Browse” button that lets you find the EXE on your hard drive.

Also, here are the registry scripts I use for Sublime Text on my system. To use, create files with the .REG extension containing the following text, modify the path to your location of the EXE - then right click on the .REG file and Merge.

  1. This replaces all calls to Notepad.exe with Sublime Text:

[code]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"
[/code]

  1. This adds Sublime Text to the right click context menu for files of all types:

[code]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"”[/code]

0 Likes

#3

Thanks Robert. That solution is better than what I wanted. How would one set highlighting options for different file types? :smiley:

0 Likes

#4

Robert, this doesn’t work on Windows XP (the notepad replacement, that is). Here is the result when I “Open With… Notepad” on my Windows XP laptop:

http://puu.sh/2fjGz

A bunch of new files open in SB. It works fine on Windows 7 (as I mentioned in my last post).

PS: There is no such folder …\My Documents\Documents, the file I was trying to open was in …\My Documents.

0 Likes

#5

As well as all the new files, SB3 opens notepad.exe as a text file (see the leftmost tab in the above screenshot). This is the code I’m using:

[code] Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\Notepad.exe]
"Debugger"="\"C:\\Program Files\\Sublime Text 3\\sublime_text.exe\""

[/code]

0 Likes

#6

@an.eireann - I also use Windows XP.

  1. To not have Sublime open notepad.exe as a text file - you have to use the -z switch when using that Debugger registry key as shown in my previous post. That is because you are technically telling Windows to use sublime_text as the debugger so that when "notepad.exe " is called it will call " notepad.exe ". The “-z” switch was added by the developer to ignore the first argument as posted here by jps.

  2. The reason you are getting separate tabs for Documents, and, My - is because %1 is being launched from the registry in Windows XP without quotes around it - and so paths with spaces in the name are being interpreted as multiple files. You just need to add the quotes around the %1 argument. To fix this - go to regedit - search the registry for all instances of notepad.exe %1 and replace it with notepad.exe "%1"

Really, the better way to solve #2 - instead of using the “Open With” dialog box - associate the extension yourself in the registry. First create a SublimeFile class type with the following registry script:

[code]Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\SublimeFile\shell]
@=“edit”

[HKEY_CLASSES_ROOT\SublimeFile\shell\edit\command]
@="“D:\PortableApps\SublimeText\sublime_text.exe” “%1"”

[HKEY_CLASSES_ROOT\SublimeFile\DefaultIcon]
@="“D:\PortableApps\SublimeText\sublime_text.exe”,0"[/code]

Then go to regedit - HKEY_CLASSES_ROOT.ext (where ext is the extension you want to associate) - and change the (Default) value to SublimeFile.

0 Likes

#7

I found the problem. It has to do with sublime messing up the registry. Details here.

0 Likes