Windows 11 Notepad

Murray Sargent

The new Windows 11 Notepad uses RichEdit and runs on up-to-date Windows 11 installations. In addition to a Windows 11 look with rounded corners and a dark-theme option, the new Notepad includes several standard RichEdit editing enhancements, such as Alt+x for entering Unicode characters, Ctrl+} for toggling between matching brackets/parentheses, multilevel undo, drag & drop, color emoji, and autoURL detection. You might guess that using a RichEdit plain-text control in Notepad would be a slam dunk. RichEdit has had plain-text controls ever since Office 97 (last century!) and they’ve been used myriad times. But those plain-text controls have been small and typically exist in dialog boxes. Notepad is often used to view large files, so high performance is important, and lines can be crazy long. And classic Notepad has been improved in various ways, such as better performance, line-ending detection (CR, LF, CRLF), and a “Show Unicode control characters” context-menu option. Accordingly, it’s taken significant effort to use RichEdit as the new Notepad’s editing engine. This post describes some additions and implementation details.

Additions to RichEdit

The classic Notepad has two handy features that weren’t implemented in RichEdit: line-ending detection (CR, LF, CRLF) and the “Show Unicode control characters” mode (discussed next). For years Notepad didn’t break Unix-convention lines that terminated with a LF (U+000A) instead of a CRLF (U+000D U+000A). I used to open the Unicode Character Data files, which contain LF-terminated lines, with WordPad and save them to convert the LF’s to CRLF’s so that Notepad would display them correctly. To fix this problem, Notepad went one better: it checked to see which line ending came first and then made that line ending the default for the file. So, a file with LF- terminated lines remains LF terminated and displayed correctly. Internally RichEdit follows the lead of Word and the Mac in terminating paragraphs with a CR and converting LF’s and CRLF’s to CR when reading in a file or storing text via an API like WM_SETTEXT or ITextRange2::SetText2. This is still the case, but you can tell RichEdit to recognize the kind of line termination in a file and use that choice for saving/copying the file by sending the EM_SETENDOFLINE message with wparam = EC_ENDOFLINE_DETECTFROMCONTENT.

Show Unicode control characters mode and emoji

Notepad has had a “Show Unicode control characters” option in its context menu for many years. This mode displays Bidi zero-width control characters using distinctive “zero-width” glyphs. This is very valuable, for example, in revealing the Bidi RLO (U+202E) and LRO (U+202D) codes that override the usual character directionalities and are sometimes used to spoof files for nefarious purposes. It also displays the zero-width joiner (ZWJ—U+200D) with a “zero-width” vertical line topped by an x. But inside emoji ZWJ sequences, such as family emojis, the mode doesn’t break the sequence apart at the ZWJ’s and doesn’t reveal the ZWJ’s by the zero-width ZWJ glyph. And classic Notepad doesn’t display ZWJ sequences and emoji in general in color.

In the new Notepad “Show Unicode control characters” mode, ZWJ sequences are broken apart at the ZWJ’s and the ZWJ’s are displayed by the ZWJ zero-width glyph. You can navigate inside the ZWJ sequence using the ← and → keys and type Alt+x to see the codes of the characters comprising the ZWJ sequence. This lets you figure out how a ZWJ sequence is constructed. For example, the new mode displays the family emoji ZWJ sequence👨‍❤️‍👩given by the codes U+1F468 ZWJ U+2764 U+FE0F ZWJ U+1F469 as

Image FamilyEmoji

Find/Replace dialog drop down

Visual Studio Code has a nifty Find/Replace dialog that drops down into the upper right of the text area. In case the dialog overlaps the starting text, the user can drag the text down just under the bottom of the dialog. The new Notepad mimics this behavior. It was a bit tricky to get RichEdit to provide the associated functionality. In rich-text formatting, the paragraph space-before and space-after properties are used to add spacing between paragraphs. Since RichEdit is a rich-text editor, it supports these properties, and it was natural to implement the drop-down space as “document space before”. The space-before value is included in the ascent of the first line in the document. The tricks came in dealing with deleting or replacing the first line and in scrolling the display correctly with a nonzero document-space-before value.

Plain-text UI improvements

We decided to match the Visual-Studio UI for selecting and not selecting the EOP character at the end of a line. This differs from Word’s UI, which tends to auto select the EOP character if you navigate next to it. Specifically, in plain-text controls, we don’t let the mouse extend the selection to include the EOP on a line or let Shift+End select the EOP. This corresponds to what gets deleted if you hit the Delete key after selecting the text. You can still select the EOP character by using Shift+→ and by extending the selection to the next line. Also, if word wrap is turned off, the insertion-point caret now follows any spaces you enter instead of ignoring the spaces.

Some implementation details

The Windows 11 Notepad uses a window for its editing canvas and windows generally use GDI for displaying text and images. GDI doesn’t have functions to display color fonts in color, whereas DirectWrite does. To be able to use DirectWrite for color emoji and other enhancements, the new Notepad therefore creates a RichEDitD2DPT window, which uses DirectWrite for text and GDI for OLE objects (Notepad doesn’t insert OLE objects).

The RichEdit build used in Notepad comes from the same sources as the RichEdit that’s loaded with Microsoft 365 applications like Word, PowerPoint, Excel, and OneNote. It’s not the Windows RichEdit in msftedit.dll. Consequently, Notepad has the latest RichEdit improvements.

We’ve fixed bugs that didn’t show up for RichEdit plain-text controls over the years partly because before Notepad, the plain-text instances have been small.

Notepad uses RichEdit classic font binding instead of the IProvideFontInfo font binding used in XAML text controls and in RichEdit controls appearing in Microsoft 365 applications. Notepad doesn’t want to load the mso libraries used in the latter since these libraries are quite large. The classic font binding has been improved but needs to add support for more scripts.

We improved RichEdit’s performance for large ASCII files such as those for core dumps. One feature that can slow down reading in a large file is autoURL detection. While reading in plain text, LF and CRLF are translated to CR for internal use and in the process the text is checked for the combination “:/”. If that combination isn’t found and only AURL_ENABLEURL is enabled, autoURL detection is bypassed.


Imagine things that can be added given the power of RichEdit. RichEdit plain-text controls have only one paragraph format, but they can have considerable character formatting. The latter is needed because 1) Unicode has over 144,000 characters and a single font is limited to 65535 glyphs, and 2) input method editors (IMEs) and spell checkers require underlines and/or text coloring. So, although the user interface only exposes one character format, the TOM object model gives access to many more properties (see ITextFont2). Accordingly, it would be possible to offer program code syntax highlighting used, for example, in Visual Studio and Visual Studio Code. But probably that should be the domain of compiler interactive development environments. Another option could be to display HTML, XML, JSON, and RTF files with indentation and toggle between XML/HTML start and end tags like Ctrl+} does for bracketed expressions, e.g., in JSON and RTF files. Large file performance needs more improvement. Please feel free to comment about bugs and wishes!


Comments are closed. Login to edit/delete your existing comments

  • Mingxin WangMicrosoft employee

    Hurray! Although it was challenging to ship the new Notepad with the Office RichEdit, we finally made it! After more than 30 years, the text engine of Notepad has eventually undocked from the OS, making it possible for the Notepad to improve fast and steadily in the future. It’s also my honor to work with you on this fascinating project!

  • Max Mustermueller

    One of the first apps I install on a brand new Windows (11) installation is always Notepad++. And the reason is that it supports syntax highlighting+ format XML/Json. And as long as the classic Notepad does not, I am not going to switch. But I appreciate every improvement of classic Notepad and I really hope in the future it will support syntax highlighting and formatting xml and json files. Both file types are widely used and reading them without both is just hurting your eyes.

    These would be my top most wishes for Windows Notepad (+ dark mode but you already got that covered so ❤️for that).

      • Peter Vertenten

        I understand that you are very proud of this accomplishment but I have a dual feeling about that. Like Max says: NP++ my tool of choice too.

        So sad that all this energy is wasted on darkmode and rounded corners. I think there are still more serious issues to be solved by MS. Things like “security”. Don’t get me wrong, all my pc’s and servers are MS and I am a huge fan of 365, the software development suites are improving with every release. But this is like your garage saying: “we fixed the left door handle” and you are like “but the engine is spilling oil like crazy”. We are all waiting for a secure OS that doesn’t get compromised because the print service is running.

        Sorry, just venting frustrations. But I am lying awake at night (yes I do) about hackers encrypting my backups or successful phishing attempts. Trying to keep the IT infrastructure up and secure with a limited budget. You know: real world problems. I am probably violating a the whole code of conduct with this but again, sorry!

        • Max Mustermueller

          Microsoft is a huuuuuge company. A lot of different people working on different things. Only because Notepad gets improved it doesn’t mean there are less resources on “security” then. Instead perhaps the team would have improved the calculator or any other for you “irrelevant” app because that’s what they are doing at Microsoft.

          And no, NP++ is not my tool of choice. I feel more like I have to use it because Notepad lacks of features. However I hate installing third party tools actually. I was a very long user of Firefox because Microsoft’s browser has lack of extensions for example or was too slow. The classic Edge then was very fast and I would have loved to use it but again, extensions are missing. Now the modern Edge has everything: Fast / Secure / Privacy + extensions and guess what, I immediately switched and never regret.

          And the same would happen with Notepad. A dark mode is very important for some people. Bringing it to a new rendering engine that supports more features is a huge improvement. Because it would allow syntax highlighting in the future. If that is done I will switch. And I am super glad that some people at Microsoft are working on these “small” features because they have been forgotten for so long time and it’s just about time to update them.

          I do agree that there are thousands of really important things to work on but again, I doubt that these people who worked on Notepad would have worked on these important things instead.

  • Salvador Sarpi

    i use it all the time to take notes, as a buffer, temp storage, unknown file type content viewer, even developing of sorts 🔥, love the new notepad!! its a big update… some behaviors had changed, but i’ll just get used to that, no issues for me.
    thanks, looking great!

  • Jan Ringoš

    I’m not a big fan of the new Notepad, nor all the other apps rewritten in those new frameworks making them use 10× more memory and feel heavy-footed to use. I’m also not fan of doing away with all tried and helpful small UX concepts, like ellipsis in menu items that open dialogs, etc. I’d still very much prefer if you instead worked on full-scale Win32 dark theme so that all Win32 apps would get dark mode for free.

    But the improvements are nice. I’m really glad it retains Clear-Type rendering, at least for the text content. And details like double-click on caption icon to close are sweet, even if it’s just a not-removed kind of thing.

    • mrcat meow

      Much agreed. Just so you know, I believe the new Notepad and the other apps use XAML Islands. Either that or WinUI 3.0.

  • Rick Brewster

    Can I use this fancy new RichEdit DLL in my own app?

    As for the new Notepad, I’d really like an option to disable smooth scrolling. I find it really slows down any workflow I have that intersects with Notepad.

    • Murray SargentMicrosoft employee

      We’re brainstorming on how to upgrade the OS RichEdit. If you have Microsoft 365 installed (Word, etc.), you can already use the riched20.dll that comes with it. On my Surface Book, it’s located in C:\Program Files\Microsoft Office\root\vfs\ProgramFilesCommonX64\Microsoft Shared\OFFICE16. Re disabling smooth scrolling, I have a feeling we’ll be offering more options. Thanks for the suggestion.

      • tc

        absolutely prioritize removing smooth scrolling. I spent most of my time with small files in notepad and the strange, slow, and inconsistent (faster wheel clicks seem to jump more lines removing scrolling but usually ends up scrolling past the point I need to be at) is extremely annoying. I as a user don’t care about internal “improvements” or “dark theme support”.

        I saw notepad get upgraded the other day and literally first thing I noticed is the WEIRD gray popups that appear when you try using alt-f-xxx hotkeys to access the stuff in file/edit/etc menus, what in the world was wrong with underlining the letters as windows UI has been doing since ’95? Why do we need some extra overlay appearing out of place to show the hotkey? it looks awful. Then the terrible inconsistent smooth scrolling that’s too SLOW on my 12900/rtx3080 machine! What in the world? Scrolling through a few 10ks of text should be INSTANT on this kind of spec machine!

  • Brandon Filer

    Great to see Notepad getting so many improvements lately! I use both Notepad and Visual Studio Code in my everyday workflows, and two features from Code I’d like to see come to Notepad are multiple selections and column selection. Personally I don’t think Notepad should ever have the feature parity of Code, as it should always open quickly and be very lightweight, but having more powerful selection capabilities would go a long way IMO.

    • Murray SargentMicrosoft employee

      Thanks for the suggestions. RichEdit has multiple selection (send EM_SETEDITSTYLE with wparam = lparam = SES_MULTISELECT), so that’d be an easy addition. When multiple selection is enabled, RichEdit also has block selection via Alt+left-mouse-button-down and drag. But it doesn’t have Visual Studio’s handy keyboard hot keys Shift+Alt+↑ and Shift+Alt+↓ to make a block selection. Good hackathon project!

  • Michael Dietrich

    Does it support multi undo/redo? The current version seems to support only a single undo.

  • Michael Bax

    Murray, the one critical feature for me is autosave. I live in a place with frequent power issues and have long lost count of the number of times I have lost text documents as a result in Windows 10 and below.

    Word autosaves both opened and new documents; so does macOS Text Edit. When will Notepad do it?


  • Jan Ringoš

    Okay, constructive feedback:
    Remember Notepad window position per file. So that after rebooting, or closing everything, I can double click the .txt files, and they all open where I had them before.
    Perhaps store the info in alternate data stream, hm?

      • Jan Ringoš

        I’d prefer ADS for two reasons:
        1) I can move the file elsewhere and it’d retains it’s position.
        2) If I delete the file, the information is deleted too. No dangling registry entries.

  • Rinaldo Rinaldini

    Search does not work anymore in text files. The keyboard is dead in the searchbox. Fix this.