Microsoft reveals little-known Notepad secrets – after *nix EOL support launched

Microsoft reveals little-known Notepad secrets – after *nix EOL support launched I ♡ gadgets, games and grammar. One-time American, full-time technologist.


Earlier this month, Microsoft proudly announced it had brought *nix end-of-line support to Notepad, more than a decade after it was first requested. The excitement from developers seems to have been quite palpable, as Microsoft has returned to the subject of Notepad in its latest MSDN blog.

In the blog, Microsoft reveals that Notepad is one of the most common test cases for apps and Windows features developed at the company. As soon as Microsoft developers need something beyond unit tests for a new feature, Notepad is seen as an ideal real-world example—so over the years, Notepad has gained some pretty cool abilities that you probably won't have heard of.

For example, what happens if you open Notepad, press File > Open, then type in https://developer-tech.com and press Enter? Surprisingly, Notepad downloads the webpage's HTML and then displays it—pretty incredible.

This actually works in most applications that use the Windows File > Open dialogue, but Notepad was among the first to do it. You can use the same trick to upload images onto a sharing site without downloading them first; just click their Upload button, and paste the URL into the dialogue box that appears.

Here's another one. What happens if you press F5 in Notepad? In most apps you'd expect a refresh or reload, but in Notepad you get a handy insertion of the current time and date. Even more cool is what happens when you add .log to the first line of a text file. If you save it, close it and open it up again, you'll see that the current time and date has been appended to the file, turning Notepad into a rudimentary diary.

Finally, Notepad has an unusual take on opening files that allow it to handle files that other programs can't manage. Here's what MSDN blog contributor Raymond Chen describes the development process that lead to this extraordinary ability:

"When [a colleague] took over ownership of Notepad, the program read the file into memory before handing it to the edit control. He kept finding little shortcuts to shave off some time here, offload some work there, and when he was done, Notepad had gotten completely out of the file-parsing business. To load a file, Notepad maps a view of the file as a memory-mapped file and uses that as the source. The code figures out the encoding, performs a code page conversion to UTF-16LE if necessary, puts the result in a memory block, and then uses the EM_SET­HANDLE message to hand that entire block to the edit control."

However, Notepad isn't the best at loading large files; other programs tend to handle this better. However, you can increase Notepad's performance considerably (on the magnitude of 10 to 100 times) by disabling the word wrap function. The Notepad2 application, which mirrors Notepad but offers a few more features and better performance, can also handle opening large files better.

Of course, Notepad isn't the text editor of choice for most developers these days, but it can still be handy if you're working on a fresh system and just need the absolute basics: plain text input, Linux line ending support and a built-in log function.

Know any good Notepad tricks? Let us know in the comments.

View Comments
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *