0

I have tried the following method:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\notepad.exe]
@="C:\\Program Files\\Sublime Text 3\\sublime_text.exe"

But it doesn't do anything. Do you have any suggestions what I could do without using another third party programme?

My expected result would be that pressing the edit button in the context menu would open the file in sublime text instead of notepad. I thought of something like redirecting things from NotePad to sublime text if possible. I also tried replacing notepad.exe itself, but it seems like sublime text only runs in the directory it was installed in.

I am using Windows 10, 64bit 1803

5
  • How do you want Sublime to open? When you click .txt files? When you click Notepad.exe? Other times? Commented Aug 10, 2018 at 21:22
  • @music2myear Whenever I press edit in the contect menu of any file. Sorry for not clarifying that before. Commented Aug 10, 2018 at 21:22
  • Please add this information to your original question as well as the version/build of Windows you are running? Also, Edit command is defined per the "default" value of the file type in HKCR. So, you'll need to find txtfile and change the EDIT command there to point to Sublime. Obviously, you won't want to edit .doc or .xls in Sublime, so you don't want EVERY file to open that way. Commented Aug 10, 2018 at 21:25
  • I see. The .doc problem doesn't seem to me like one, as I usually open these documents instead of pressing edit, which currently does the same thing. But you are right, it would be more convenient to redirect it from notepad to sublime text somehow. Commented Aug 10, 2018 at 21:30
  • Try using NotepadReplacer as documented here: winhelponline.com/blog/… Commented Aug 10, 2018 at 21:33

1 Answer 1

0

To do this in your user profile only:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\txtfile\shell]
@="sublimate"

[HKEY_CURRENT_USER\Software\Classes\txtfile\shell\sublimate]
@="Edit with Sublime Text"

[HKEY_CURRENT_USER\Software\Classes\txtfile\shell\sublimate\command]
@=hex(2):22,00,25,00,50,00,52,00,4f,00,47,00,52,00,41,00,4d,00,46,00,49,00,4c,\
  00,45,00,53,00,25,00,5c,00,5c,00,53,00,75,00,62,00,6c,00,69,00,6d,00,65,00,\
  20,00,54,00,65,00,78,00,74,00,20,00,33,00,5c,00,5c,00,73,00,75,00,62,00,6c,\
  00,69,00,6d,00,65,00,5f,00,74,00,65,00,78,00,74,00,2e,00,65,00,78,00,65,00,\
  22,00,20,00,22,00,25,00,31,00,22,00,00,00

This adds an additional context menu item and makes it the default; it lets you keep the normal notepad-targeting "Open" item in case you need it.

To do the same system-wide, replace HKEY_CURRENT_USER with HKEY_LOCAL_MACHINE.

Apologies for the hex string; this is a REG_EXPAND_SZ value that uses %PROGRAMFILES% rather than hardcoding the path. I tried using reg.exe instead of regedit, but could not find a way to get the quoted path and the quoted "%1" placeholder to work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .