Sublime as default editor

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.

This will add a Sublime right click menu entry to all files:

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:

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.

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:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.ext]
@="SublimeFile"

1: You can also set your associations in Control Panel:

Control Panel > Default Programs > Associate a file or protocol with a specific program:

enter image description here

2: Or, call it from code via IApplicationAssociationRegistrationUI::LaunchAdvancedAssociationUI ;)

HRESULT LaunchAdvancedAssociationUI(
   [in]  LPCWSTR pszAppRegName
);

Edit on Nov 21, 2014

Tim Lewis pointed out in the comment that there is a more generic version at http://www.binaryfortress.com/NotepadReplacer/, which works better.

Original Answer

Try this: https://github.com/grumpydev/Sublime-Notepad-Replacement


Actually it is not my answer, I have just googled it:

  1. Open regedit (Win+R, type "regedit", select OK).
  2. Navigate to HKEY_CLASSES_ROOT\Applications\sublime_text.exe\shell\open\command
  3. Verify that the path is accurate, correct it if it is not. Exit regedit.
  4. Open task manager via Ctrl+Alt+Del (or Ctrl+Shift+Esc for later versions of Windows), kill explorer.exe, go to run (Win+R) and type "explorer.exe" (or skip this step and simply reboot).
  5. 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.

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).