Saturday, March 19, 2005

"Interesting" Notepad Bug

I've been writing my own text editor control. Although only a moron would actually do this, I'm learning a lot along the way. One of the toughest bits of it is to correctly implement word wrapping, particularly because I want to get it right not just for ASCII characters, but for others as well, like East Asian languages. (While I may be a moron, I'm not insane: I'm using the Uniscribe API to do all the hard parts.)

One of my challenges is that I don't always know what the “right” way to do something is. For example, should there be an invisible character representing the newline that shows up when drag selecting? Should the width of this character count against word wrapping?

When faced with a challenge like this, I often fire up another program and see what its authors decided to do. One of these that I frequently consult is Word. Another is Notepad. I figure I ought to at least be able to provide what Notepad does, and at best I'd match the capabilities of Word (although I'm not quite so mad as to actually target that). Well, tonight as I was trying to work out the kinks in my word breaking algorithm, I saw an interesting quirk in Notepad's line breaking capabilities. It surprised me because I assume Notepad to be one of the most mature pieces of software in Windows. Anyway, try this:

  1. Fire up Notepad.

  2. Make sure that Word Wrap is enabled.

  3. Type some gibberish that has some spaces in it.

  4. As soon as you type something that wraps to the next line, start hitting backspace.

  5. Note that backspacing to the point where the word that wrapped becomes short enough that it could fit on the previous line does not actually “unwrap“.

  6. Marvel that the amount of utility in this information is so small as to be undetectable by modern scientific instruments. :)


  1. I think that most "power users" and developers don't use notepad much (I use notepad2) and most likely they are the only ones who might worry about such a thing.

    That said, you do have to chuckle, because Notepad was around in Windows 3.0 (or possibly before)?

  2. I use Notepad2 myself. But Notepad2 is based around Scintilla, which has a whole raft of bugs (although it's still a great control). That's why I was observing Notepad, rather than Notepad2.

  3. Let's go ahead and crush any last illusion of notepad's technical excellence... here's a related bug. More like a punted feature, perhaps, but so lame I consider it a bug:

    -- start notepad

    -- disable wordwrap, if not already

    -- enable statusbar

    -- type some junk

    -- (re)enable wordwrap

    What? No statusbar? Try to reenable it. No can do!

    I have it on good authority that notepad was misreporting the line number when ww was enabled, this bug was only noticed shortly before XP shipped, and the only thing they could do w/o resetting escrow testing was to disable the statusbar+wordwrap combo. Groan..

  4. Heh. Yeah, I suspect Notepad bugs don't get real high on the priority list.

    BTW, if you haven't tried Notepad2, you really ought to. It's free.

  5. Do you mind if I pretend I discovered this bug to impress the ladies? :-p

  6. Be my guest: I already caught my limit. ;)

  7. Really buggy Notepad.

    Once upon a time, I have been using notepad to write HTML documents. I usually turn Word Wrap on. During the use, misterious bugs showed up in Notepad - sometimes the cursor can be moved to some position where nothing exists, and if I typed something, they would appear together with some text on the next line. In the end, I found it is that when a file is saved, it updated the word wrapped layout internally (with something just you said, type some gibberish that has some spaces in it, and then backspace to), but it did not refresh the display.

  8. Hmmm notepad exists from win 3.1 and it's not fixed yet?! If microsoft is not able to develop a "word wrap" i'm worrying about vista :(

  9. That line of reasoning is a bit faulty. For one thing, it assumes that notepad and vista are equivalent in importance to Microsoft. For another it assumes that vista and notepad are equivalent in functionality. Neither is true.

    Anyone who's expecting Vista to be bug-free is going to be surprised. However, I expect it to be a high-quality product, in line with the increasing stability we've experienced in Microsoft products historically.

  10. Notepad is part of these easy tools one can want to use at anytime - and it is usually run by default to open txt files...

    How come such an *obvious* bug of such a useful application can be let unfixed ?

    Of course, this is not a ludicrous Vista vs Notepad comparison... Notepad could be fixed in 10 minutes, it just show in which spirit microsoft develops its applications.

    Notepad is so simple its flaws can be easily detected ; but what about the internal kernel of an OS? it's a black box where nobody but some engineers can look inside (unlike Linux that can be seen by anybody)...

    I agree the reliability of the OS is increasing, but what does it cost? Why is it slow? Why "wine" on Linux does the same thing faster? Because you cannot see inside bugs fixed with "band aid".

    If Notepad fails, "well just dont use the word wrap option", what if the OS fails? The computer stops, so it has to be fixed.

    Just a question of spirit...

  11. If you think Notepad is simple, you should try writing a clone. I'm writing a text editor control right now, and it turns out there are lots of complex issues to deal with, *especially* around things like word wrapping, left to right, etc.

    I'm a big fan of open source. I've worked on several major projects myself. And interestingly, I find that the quality of open source is generally far worse than that of Microsoft's software. There are a few exceptions, but that's the general rule.

  12. I must agree that MS did some good stuff, Excel for instance (while openOffice is great as well... and free.)

    The good thing about open source is that everybody (meaning all developpers) can fix bugs, or implements their own version. The bad think is that some software fit only the needs of a particular home developper where no manager had to cope with requirements and explain himself to somebody. And some useful programs are really painful for that (being too specific and not coping with general needs).

    However the main MS softs get a good equivalent on the open source side (eg did you check out the latest SuSE?). And I prefer a less "sexy" tool that is free and that is customizable than something expensive and opaque.

    Well, being a developper myself, working on both platforms, let me tell you that the MS tendancy to keep its software structure as a black box is really annoying. MS became such a big company that their APIs and documentation lack of consistency. Most of the time, I better get the free open source library to fit my needs than trying to cope with MS specifities/inconsistencies/ambiguous doc/bugs/"need to upgrade to latest $$ version" not mentioning the weirdness of some of their internal implementations...

    From the user side, Windows is used at so many places that anyone will always (for the time being) be able to find a needed program to do something in particular.

    From a developper perspective, MS shows a lot of weaknesses which are not visible from the outside: their management. Imho, MS gets a handle (or a bit more) of very competent people working on the OS kernel in a well managed structured team. For the rest, including the top, they grew during the very profitable years of MS (say, up to a few years from now) and have no idea of what is a good management. How could they personnaly acknowledge this, especially while the company is still making a huge profit (resting on their laurels)...? Time will tell.

    Imho, MS key people, being insanely paid, will feel more and more the terrible frustration of being in this company *only* for the money.

    What makes a good movie is first its direction, not (only) the money that can be invested in.

    Oh maybe i'm wandering a bit off the point...

  13. N2 is a great replacement for the original. How many times have you needed a dual clipboard, since N2 comes with the source this is a great chance to add it! I wonder why this feature goes overlooked with so many editors?

  14. Get emacs and be done with it (unless you are hardcore and want to use Vi - ugh modes)

  15. I use emacs every day. I've even written several major modes for it. :)

  16. Notepad got buggy in Windows XP. In earlier versions of Windows it actually worked; but no longer.

  17. here's another bug

    type in 3 characters lowercase

    hit the spacebar

    type in 4 characters lowercase

    hit the spacebar

    type in 3 characters lowercase

    hit the spacebar

    type in 5 character lowercase


    close the file

    reopen it.

    what do u see???

  18. Well for opensource.....Coding is not worse....

    Don't you know...Microsoft's so called Innovation comes from Open Source IDeaz only...

    Where do you think ASP.NET Came from....

    Heard of Struts Framework...Which came back a year earlier...

    Heard of Java in 1997...CLR Clone of JVM.....

    It's easy to put a price tag on decorating it....

    Decorator pattern applies to these guys........Nothing else...and you pay for it....tats why...they work so hard to make the software.....with all glitz and glamour...

    Remember all that glitters is not gold!

  19. Animesh: this is one of the oldest claims in the book. It is neither wholly true nor wholly false. And in any event it is completely irrelevant - every piece of interesting software looks a lot like something that came before it. Including all the "open source" projects you site (the JVM is *definitely* not open source).

  20. i got a fwd saying the below:

    Hi guys,

    Try this...Bug

    For those of you using Windows, do the following:

    1.) Open an empty notepad file

    2.) Type "Bush hid the facts" (without the quotes)

    3.) Save it

    4.) Close it, and re-open it.

    Any explanation to the above?

  21. Yeah. This:

  22. Actualy u can also type....


    Any letter in place of 'Z' or mixed combination!

  23. Has anybody else run into a problem pasting large amounts of text from notepad into another program (e.g. Word) and getting odd line breaks inserted for you? It doesn't occur if you turn Word Wrap off before copying the text. It seems the "soft" line breaks are getting copied with the text as "hard" line breaks.

    Microsoft has a lot of money. This may sound harsh, but if they didn't have the competence to fix Notepad in a timely fashion (how many years has it been now since XP was released? 3? 4?), then they should simply have bought out a working notepad program from some small company. It would be a pittance in the long term.



  24. Microsoft should fix notepad to help scientifically minded developers. Pure text is the way to go.

  25. If you want free BEST notepad, try NOTEPAD++

    Best for Developers, designers, programmers...

  26. Blaming Microsoft on a tiny notepad bug is not logic. And think of it in this way, all the programmers there at Microsoft are not not Gods. They too does mistakes like we all do.(if u are a programmer, u know...). This doesn't mean that Bill Gates planned a bug in XP notepad so that he can sell Vista fixing it. Open Source and free softwares are nice to talk about. If the standard of those softwares exceeds that of Microsoft, why Bill Gates remains the richest ?


  27. I use Notepad++ to replace Notepad :

    The reason I use Notepad++ is its MDI (Multi-Document Interface just like firefox).

    To replace your notepad by notepad++, you have to :

    1. Download and install Notepad++ :

    2. Download Notepad++ launcher :

    3. Copy notepad.exe which comes with this package into 3 directories (in given order) :

    i. c:\windows\system32\dllcache

    ii. c:\windows\system32

    iii. c:\windows

    When you replace notepad.exe in c:\windows\system32 and c:\windows, a "Windows File Protection" message box appears, click Cancel. Then another message box appears, click OK.

    Now Notepad++ is your default Notepad.

  28. " # re: "Interesting" Notepad Bug


    Posted @ 3/20/2005 12:08 PM

    Let's go ahead and crush any last illusion of notepad's technical excellence... here's a related bug. More like a punted feature, perhaps, but so lame I consider it a bug:

    -- start notepad

    -- disable wordwrap, if not already

    -- enable statusbar

    -- type some junk

    -- (re)enable wordwrap

    What? No statusbar? Try to reenable it. No can do!

    I have it on good authority that notepad was misreporting the line number when ww was enabled, this bug was only noticed shortly before XP shipped, and the only thing they could do w/o resetting escrow testing was to disable the statusbar+wordwrap combo. Groan.. "

    This is complete rubbish - if you enable line-wrapping and line numbering together you have a conflict of interest. Do you split the line numbers such that there are gaps when wrapping occurs or do you ignore the wrapping and ensure there are no gaps in the line numbers - MS made the decision not to allow the conflict, it's NOT a bug!

  29. "Microsoft has a lot of money. This may sound harsh, but if they didn't have the competence to fix Notepad in a timely fashion (how many years has it been now since XP was released? 3? 4..."

    Absolutely right, Richard. Microsoft has made its billions by ripping people off. Fundamental functionality (e.g. search in Explorer) has been broken and never fixed for years. Gates and Ballmer are rich because they are nothing more than criminals.

    If you look at any individual or company that has accumulated fantastic amounts of money, you'll see there is always some sort of criminal activity at work. It may not strictly be against the letter of the law, but these people should not be sleeping soundly, as they have swindled millions of innocent individuals.

  30. This day I too encountered some issue with notepad.. donno whether this is a bug or an issue with my machine..!

  31. A lot of the word wrap bugs have been around since Windows 3.0. I've used every version, and still do on occasion. It still shocks me to see the same bugs from 3.0 in xp sp2...classic "I don't care" service and support.

  32. For all that notepad is buggy, it is one of the only apps that does codepage handling, AND UTF-8, AND UCS-2 encoding right. As soon as you go outside of ASCII text, 90% of the editors in the world - while nice and full of features - either crash or display junk. Another 9% of editors will handle UTF-8 as well, but not non-Unicode MBCS (multi-byte character sets, such as Chinese).

    Even Emacs, the supposed benchmark of hard-code text editing, still cannot handle Unicode properly, 20 years later.

    Because of this, and because Notepad is on every windows system ever, it still gets used, despite the problems.

  33. Hi i tried but didn't see anything.......

  34. Microsoft fails to solve these problem- Really Interesting

    An Indian discovered that nobody can create a FOLDER anywhere on the computer which can be named as "CON". This is something pretty cool...and unbelievable... At Microsoft the whole Team, couldn't answer why this happened!


    Folders with name: CON, PRN, AUX, CLOCK$, NUL, COM1, COM2, COM3, COM4, COM5,

    COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, & LPT9

    cant be created using Windows Explorer or Command Prompt directly! ( Try this

    out.. right click on your desktop and try creating folder named "con"it changes

    back to "ew Folder" )

    This is prevented as XP terms these folders as SYSTEM Folder Names reserved only

    for the Operating System.. But there is a backdoor...(this trick is to create

    system folders on XP through command prompt )

    Try this:


    Syntax:md \\.\\$path

    Example:prompt>md \\.\\C:\con

    Explanation: This would create a folder named "con" on your "C Drive"

    Similarly to delete such folder:


    Syntax:rd/s \\.\\$path

    Example:prompt>rd/s \\.\\C:\con

    Explanation: This would remove the folder named "con"!

    Note: rd(Remove Directory) command is used with "/s" switch as otherwise it

    would give error that "folder is not empty"!

    On another hand...if you ever wondered how to create a folder with no

    name...then try this:

    Create a New Folder from Windows Explorer

    Select rename & type: "ALT+255"(Use Numpad)..that’s it!

    ALT+255 stand for blank character in it still accepts your folder name!

  35. I have encountered bugs in Notepad in both XP and 98 where lines disappear or text appears on the wrong line. Often selecting all, then de-selecting seems to help. I prefer to use the Text application in the old Tandy DeskMate GUI - Tandy had it right in 1988, Microsoft still can't get it straight 20 years later...