DEV Community

Cover image for I Built a 4.4 MB Windows Text Editor That Switches Between Notepad-Style Editing and Vim
HideyukiMORI
HideyukiMORI

Posted on Edited on

I Built a 4.4 MB Windows Text Editor That Switches Between Notepad-Style Editing and Vim

Sometimes I just want to open a file, change one line, and leave. Notepad is fine until I need search across a folder or a Vim motion. A full IDE is more than that moment needs.

So I built NeNe Nib, a text editor for Windows 11. It's one 4.4 MB executable (as Windows reports it; 4,571,648 bytes) with no runtime to install. It works like Notepad by default, and Ctrl+Shift+Space switches it to Vim editing.

Get NeNe Nib on the Microsoft Store (free)

What it does

  • Ordinary editing or Vim. Switch with Ctrl+Shift+Space or a click on the status bar.
  • Vim checked against real Vim. The Vim layer is written from scratch and tested against 6,892 cases generated by Vim 9.1. In NORMAL mode the Japanese IME turns off, and INSERT turns it back on.
  • Large files. UTF-8 files up to 1 GiB load in the background.
  • Find things fast. Ctrl+P lists tabs, bookmarks, recent files and folder files with a preview. Ctrl+Shift+F searches a project.
  • Markdown preview. Tables, GitHub alerts, colored code blocks and clickable task lists.
  • 125 themes and syntax colors for 25 languages.
  • Private by default. No account, no usage data, and no network connections of its own.

On my development PC (Core i9-10850K, RTX 3090), the app's own timing shows 45.7 ms from process creation to presenting the first frame, and 0.47 ms from receiving a keystroke to presenting its frame. Both are medians of five runs and exclude OS composition and display time.

What it doesn't do

  • It runs only on Windows 11 (22H2 or later, x64). Windows 10 is not supported.
  • Vim indent is fixed to 8-column tabs: :set sw=4 and :set expandtab are refused for now.
  • It doesn't load .vimrc files or Vim plugins. Mappings are stored in Nib's own settings.
  • Search patterns don't support \v yet, and NORMAL R and uppercase marks are missing.
  • :sort isn't there yet, and :g supports only d and s.
  • Language-server support is off by default, and you install the server yourself.
  • Project search reads UTF-8 files only.

Fast startup without slowing down typing

Nib is written in C++23 on plain Win32, Direct2D and DirectWrite, with no UI library. The executable imports 15 DLLs, all part of Windows (8 are delay-loaded).

The first frame made the biggest difference to startup.

Initializing a Direct3D device takes about 150 ms on my NVIDIA setup, while a WARP (software) device takes about 9 ms.

So Nib draws the first frame with WARP while the GPU initializes on another thread, then switches about 170 ms later. That took the first frame from 177.65 ms to 40.6 ms on my machine at the time.

To keep typing fast too, the WARP frame goes to a dedicated child window instead of the main window:

  1. Create a child window that covers the main window's client area, and let WARP draw there.
  2. Give the main window's DirectComposition target only a swap chain created on the hardware device.
  3. When the GPU is ready, present the same frame on the main window, then destroy the child window.

With this design, my measurements at the time showed a 41.3 ms startup and 0.638 ms per keystroke.

Try it

If you want something as easy to open as Notepad, with Vim there when you reach for it, I'd love for you to try it. Bug reports and ideas are welcome on GitHub.

Get NeNe Nib on the Microsoft Store (free)

A ZIP is on the v1.1.0 release page. Its executable is unsigned, so SmartScreen may warn you; the Store version is the easier path.

Top comments (6)

Collapse
 
csm18 profile image
csm •

Awesome project! 🔥

Collapse
 
hideyukimori profile image
HideyukiMORI •

Thank you! If you try it, I'd love to hear how it feels.

Collapse
 
csm18 profile image
csm •

😅 I don't have a windows pc, if I had, would have tried it!

Thread Thread
 
hideyukimori profile image
HideyukiMORI •

No worries, thanks for checking it out anyway!

Collapse
 
userxnom profile image
Abdullah Naseer •

The startup workaround is the part that stuck with me — drawing the first frame on a hidden child window with WARP just to keep DWM from remembering the slow path feels like the kind of fix you only find by measuring. Did that 1.25 ms keystroke regression disappear for good once WARP was off the main window, or does it creep back in some driver states? Also, with 6,892 Vim cases generated from Vim 9.1, which area fails most often when you add a feature — text objects, operators, or search?

Collapse
 
hideyukimori profile image
HideyukiMORI •

Thanks for reading it so closely! With WARP off the main window, the slowdown hasn't come back in my speed checks: version 1.1.0 measured 0.47 ms per keystroke from input to Present. I've only tested this on one NVIDIA machine, though, so I can't say how other drivers or driver states behave.

On the Vim cases, I don't keep failure counts by area, so I can't give you an honest ranking. That would be a useful thing to start tracking.

If you try it and see different behavior on your setup, I'd love to hear about it.