Sublime Forum

Windows Notepad Replacement

#1

I’d like to see a “-z” command line switch that would allow Sublime Text to replace notepad.exe on windows machines.

Programmers Notepad blog explains this method
( untidy.net/blog/2009/11/03/repla … n-options/ ):

This way we can do this to register Sublime Text as a Notepad.exe replacement;
reg.bat in sublime program folder:

reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v "Debugger" /t REG_SZ /d "\"%~dp0sublimetext.exe\" -z" /f

Thanks.

0 Likes

Sublime Text 3 Beta
Windows: Can't set SB3 as default text editor
#2

In case you don’t spot it, I’ve created a little launcher/installer for doing this:

0 Likes

#3

Great!
Thanks!

I had to install Microsoft Visual C++ 2010 (redistributable)…
So I hope this can be incorporated into Sublime Text.

0 Likes

#4

In the latest version of Sublime Text 2, “-z” can be passed on the command line, and the following command will be ignored. I haven’t tested this with the registry key to enable Notepad replacement, but my understanding is that’s all that’s required.

0 Likes

#5

I’m not using Sublime Text 2, but I went ahead and tested it for you.

It’s not working when opening files in paths with spaces in them.
For example, I open the file “J:\My Dropbox\Workspace\blah.txt”, Sublime tries to open a file named “My”

GrumpyDev’s launcher works in all cases for what it’s worth.
Tested on 20110203 x64/386 portables and installed as well.

Here’s the ReplaceNotepad.bat

reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v "Debugger" /t REG_SZ /d "\"%~dp0sublime_text.exe\" -z" /f
0 Likes

#6

Yep, when you launch it with the debugger trick it doesn’t surround the filename with quotes - no idea why, but it doesn’t.

My launcher thingy makes sure the parameters (ignoring -z and the one after it) are quoted.

0 Likes

#7

Hi Grumpydev, I’m using Windows 7 for 64 bit, and when I install this, it doesn’t quite work. Something gets run, but sublime doesn’t get started at all. Sublime gets installed in Program Folders(x86) folder, but that is referenced correctly in the registry keys.

Do you have any pointers for Windows 7, 64 ?

0 Likes

#8

[quote=“l1n3n01z”]Hi Grumpydev, I’m using Windows 7 for 64 bit, and when I install this, it doesn’t quite work. Something gets run, but sublime doesn’t get started at all. Sublime gets installed in Program Folders(x86) folder, but that is referenced correctly in the registry keys.

Do you have any pointers for Windows 7, 64 ?[/quote]

I’m not Grumpydev heh but I think I know what is wrong. If you look at the source code the exe is actually calling sublimetext.exe and not sublime_text.exe what you can do is rename the sublime_text.exe to sublimetext.exe and it should work. I’m not sure though if that breaks anything else, but so far it’s been working fine for me.

0 Likes

#9

Very astute! This worked perfectly, atomi. Thanks a lot!

0 Likes

#10

Thanks man!

0 Likes

#11

Update sublime text 3

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe]
“Debugger”="“D:\portables\Sublime Text 3\sublime_text.exe” -z"
@=""

this work for me! thanks

0 Likes

#12

This won’t be able to open files correctly. You need some launcher if you want to be able to open files correctly, either Sublime Launcher or Notepad Replacer.

0 Likes