Why does Windows Vista's Notepad randomly move the cursor after saving a file?

15

3

What is happening:

Initially my cursor was at "initially here". When I press Ctrl+S to save the file my cursor automatically moves to the second position.

After many tries, I've seen that it randomly moves to a point one or two lines above the place where it initially was.

alt text

(The red line is the cursor - I've drawn it manually since it wont show up in printscreen)

Did anyone notice this thing?

My version of Notepad is:

alt text

It is a problem since I keep typing and whenever I save, I have to manually bring the cursor down to the correct place or else I am typing somewhere between the lines!

Lazer

Posted 2009-10-19T06:14:12.653

Reputation: 13 841

1I'm guessing there should be some images in the post but it only shows "alt text" for me. – T. Kaltnekar – 2009-10-19T06:29:06.540

@T. Kaltnekar Is it fixed now? – Lazer – 2009-10-19T06:32:48.187

Yes, images are visible now. – T. Kaltnekar – 2009-10-19T06:40:46.783

Seems to be a bug, I can reproduce it. Looks like it's related to word wrapping somehow. Suggest you use notepad++ as micmcg suggested. – T. Kaltnekar – 2009-10-19T06:57:50.570

it randomly moves to a point one or two lines above the place where it initially was, so even random for the very same text, with the very same starting point of the cursor? – Arjan – 2009-10-19T06:59:38.663

1From test I did - if I added a few chars and saved it didn't move. If I added enough text so it wrapped at end of line cursor moved after saving. More times it wrapped the more it moved. – T. Kaltnekar – 2009-10-19T07:17:43.667

Hmmm, I guess not too many people use wrapping in Notepad. (Especially as the screenshot seems to show there's no visual indication when wrapping is applied?) – Arjan – 2009-10-19T08:08:41.347

Things get even weirder if you change width of the window. After you change width and press Ctrl+S, the cursor moves. However when you start typing you are actually typing at the end of text so it seems Notepad just doesn't update wrapping for new width. This is not the case in described problem, there cursor is actually positioned in the middle of the text after saving and is not just displaying incorrectly. – T. Kaltnekar – 2009-10-19T08:45:03.803

Answers

25

I noticed this problem in Windows XP Notepad. It only happens if word wrap is on when you save. The amount the cursor moves back is related to the number of new wrap points before the cursor since the last save. The more new wrap points before the cursor, the further the cursor moves back.

Why does the cursor move? When you save with word wrap on, Notepad inserts CR CR LF characters at each wrap point in the display window (but not in the saved file). The number of characters from the beginning of the display window to the cursor stays the same, but because of the extra CR CR LF characters, the cursor appears to move backward.

For more information and a step-by-step example, see Notepad bug: Saving with word wrap on inserts CR CR LF characters in the display window.

Bavi_H

Posted 2009-10-19T06:14:12.653

Reputation: 6 137

1thanks for adding info. posts consisting primarily of a link are discouraged here to minimize future problems with broken links. – quack quixote – 2010-02-17T04:25:39.497

the answer I was waiting for! – Lazer – 2010-02-17T05:00:57.900

This problem also occurs on Windows 7 and 8.x. I reported it as a bug to Microsoft, on the off chance that they might fix it some day.

– boot13 – 2015-09-17T18:14:29.347

1Actually, this bug goes all the way back to the days of Windows for Workgroups 3.11 (may go back even further). I used to use Windows Write a lot and it did the exact same thing whenever you'd save with word wrap on, though it would also change the word-wrapping slightly but not update the display, causing things to become jumbled. When Windows 95 came out, Write was renamed to Notepad and the cursor bug remained, where it remains still. In other words, this bug has existed for at least 20 years and still M$ hasn't gotten around to fixing it. – Kris Craig – 2015-10-27T23:43:05.583

2Write -- I'm pretty sure Write has nothing to do with Notepad. Windows 3.1 and 3.11 for Workgroups had both Notepad and Write, they were separate programs. The modern equivalent of Write is WordPad, not Notepad. I don't remember a bug like this in Write, but if there was one, I suspect it's not related to this Notepad bug. The Notepad bug is caused by poor use of the EM_FMTLINES message of a multi-line edit control. I think Write and WordPad use rich text controls, so I doubt it's the same thing. @KrisCraig – Bavi_H – 2015-10-31T14:42:36.383

2How long the bug has existed -- I have used versions of Notepad in Windows 3.1, 3.11 for Workgroups, 95, XP, 7, 8, 8.1, and 10. The versions from 3.1 to 95 didn't have this bug, and the versions from XP to 10 do have this bug. In this blog post, the author says he's noticed the bug in Windows 2000 and after. I guess somewhere around Windows 2000, Notepad was revised to use EM_FMTLINES, and this bug has remained ever since. – Bavi_H – 2015-10-31T14:42:54.973

9

Regardless of whether this is a bug, if you are doing anything in notepad regularly enough for this to be an issue, you need to start using a better text editor. Try the free notepad++ for a start - http://notepad-plus.sourceforge.net/

micmcg

Posted 2009-10-19T06:14:12.653

Reputation: 383

2I have had... issues with Notepad++ crashing and/or hanging on file open on multiple systems quite often. Other than that, a great editor ;) – Ed S. – 2009-10-19T08:04:58.953

see SO for a list of popular text editors: http://stackoverflow.com/questions/14155/windows-based-text-editors

– lexu – 2009-10-19T08:35:41.357

0

(Can't post as a comment because I don't have enough reputation.)

According to this site, it was fixed by at least Windows 10 version 1511 (November 2015).

According to this site, the bug existed in Windows 10 on October 18 2015.

If we're going by major versions of Windows 10, the initial release was 1507, then the next major version was 1511. So by deduction, version 1511 was the first major update that had this bug fixed.

user868538

Posted 2009-10-19T06:14:12.653

Reputation: 43

-2

Open your Registry editor, and in Current User locate the following key:

HKEY_CURRENT_USER\Software\Microsoft\Notepad

then

  1. Create a new DWORD value called fSavePageSettings and set it to "1"
  2. if fSaveWindowPositions doesn't exist then Create DWORD and set it to "1"

jama.jamazoka

Posted 2009-10-19T06:14:12.653

Reputation: 1

I found a reference to these registry settings on the Microsoft Answers site, but the settings didn't fix the problem, which also occurs on Windows 7 and 8.

– boot13 – 2015-09-17T18:12:47.930

2What do these keys mean and what is their effect? – Der Hochstapler – 2012-08-15T16:28:09.420