Why notepad is sometimes slow opening large files and how to make it fast

Ever notice how notepad can be really slow opening large files? Yeah I know why use notepad at all? For the simple reason that it might be the only editor on some random server that you logon to look at logs etc. Well there is Wordpad too but the default association for text and log files is to notepad and by the time you've double clicked a log file it might be too late. Also Wordpad is more heavyweight and can be lot slower scolling through and searching for text etc.

So you open some really large log file (in notepad) and notice the excruciatingly long time it takes. One day I got really frustrated and decided to investigate a bit. After a while I realized that even actions like maximizing or changing the size of the window took very long and a light bulb turned on that somehow notepad is redoing the whole layout of the text again so perhaps the word wrap feature is responsible. After all the word wrap feature (menu Format->Word Wrap) causes notepad to break lines at the visible width so that must be taking some time. Turns out that indeed if you switch word wrap off notepad becomes lightning fast. I tested with two log files of 11 MB and 103 MB on a Dual P4 3.2 GHz with HyperThreading on. For the 11 MB file I got times of around 16 s with word wrap on and 1.5 s with word wrap off! For the 103 MB it was 135 s and 15 s! I couldn't believe it was so simple and hadn't heard about this anywhere so I asked the people in my team if anyone knew about this. Apparently no one knew. I wonder how many people have realized this.

Now the problem is that at some point in time you've probably turned on word wrap in notepad and then forgottten all about it. It stays on and you keep suffering slow notepad file open times. I wish notepad had an option to turn word wrap off for files above a certain size. After all most text files you are going to use word wrap on wouldn't be too big. My suggestion is to keep word wrap off all the time and just make the default size of notepad as big as your screen allows. And if you really do need to use it then don't forget to turn it off lest you find yourself cursing the next time you open a large file :)