Home Download Buy Blog Forum Support

Windows Notepad Replacement

Windows Notepad Replacement

Postby atomi on Thu Jan 20, 2011 5:11 pm

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
( http://untidy.net/blog/2009/11/03/repla ... n-options/ ):

"The –z tells PN to ignore the next parameter, which when using Image File Execution Options is the process name that we’re replacing – the full path to notepad.exe in this case."


This way we can do this to register Sublime Text as a Notepad.exe replacement;
reg.bat in sublime program folder:
Code: Select all
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.
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: Windows Notepad Replacement

Postby Grumpydev on Mon Jan 31, 2011 2:34 pm

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

viewtopic.php?f=2&t=1541
Grumpydev
 
Posts: 3
Joined: Mon Jan 31, 2011 1:59 pm

Re: Windows Notepad Replacement

Postby atomi on Fri Feb 04, 2011 9:12 pm

Great!
Thanks!

I had to install Microsoft Visual C++ 2010 (redistributable)...
So I hope this can be incorporated into Sublime Text.
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: Windows Notepad Replacement

Postby jps on Fri Feb 04, 2011 10:10 pm

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.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: Windows Notepad Replacement

Postby atomi on Sat Feb 05, 2011 4:47 am

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
Code: Select all
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
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: Windows Notepad Replacement

Postby Grumpydev on Sat Feb 05, 2011 8:49 am

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.
Grumpydev
 
Posts: 3
Joined: Mon Jan 31, 2011 1:59 pm

Re: Windows Notepad Replacement

Postby l1n3n01z on Fri Mar 25, 2011 4:12 pm

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 ?
l1n3n01z
 
Posts: 2
Joined: Fri Mar 25, 2011 4:08 pm

Re: Windows Notepad Replacement

Postby atomi on Mon Mar 28, 2011 1:09 am

l1n3n01z wrote: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 ?



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.
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: Windows Notepad Replacement

Postby l1n3n01z on Tue Mar 29, 2011 2:11 pm

Very astute! This worked perfectly, atomi. Thanks a lot!
l1n3n01z
 
Posts: 2
Joined: Fri Mar 25, 2011 4:08 pm

Re: Windows Notepad Replacement

Postby chrisemersonnc on Mon Feb 17, 2014 2:50 pm

atomi wrote: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.


Thanks man!
chrisemersonnc
 
Posts: 2
Joined: Tue Oct 02, 2012 1:27 pm


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: No registered users and 11 guests