In NeNe Nib 1.2.0, the caret glides instead of teleporting, and it never holds your typing back.
It's hard to describe and hard to stop noticing once you've typed with it. Here it is in real time:
What's in this post:
- What the motion looks like, and how to turn it on
- Why it feels smooth, and why it never makes you wait
- Sparks: a small burst in your theme's colors on every keystroke
- Why both are off by default
The editor
NeNe Nib is my text editor for Windows 11, written in C++23 on Win32 and Direct2D. It works like Notepad by default, and Ctrl+Shift+Space switches it to Vim editing. Version 1.1.0 showed a 16 MiB file in 117 ms, which I measured against Windows Notepad last week.
1.2.0 adds two things that are just for the feel of typing: caret motion and sparks.
Turn it on
Both switches are in the settings drawer. In Vim mode you can also type them:
:set caretmotion
:set caretmotiontime=120
:set caretsparks
caretmotion makes the caret glide, caretmotiontime sets how long a glide takes (40 to 300 ms, 120 by default), and caretsparks throws a small burst on every keystroke. The two switches are independent. You can have the glide without the sparks, or the other way around.
Why it feels smooth
The front lands first
The caret isn't moved as one rectangle. Each of its four corners travels on its own, and the corners on the side it's moving toward arrive first:
| Corner | Arrives at | With 120 ms |
|---|---|---|
| Front-most | 45% of the time | 54 ms |
| Second | 60% | 72 ms |
| Third | 85% | 102 ms |
| Back-most | 100% | 120 ms |
With the 120 ms default, the leading corner lands in 54 ms. For a moment the caret stretches into a short trail pointing back the way it came, then settles back into a caret. Each corner follows a cubic ease-out curve, so it starts fast and slows into place. The trail has a soft edge, and it's drawn in your theme's colors.
This is the core of it, from CaretGlide.cpp:
CaretQuad caret_motion_quad(const CaretQuad &from, const CaretQuad &to, std::uint32_t elapsed,
std::uint32_t duration) noexcept
{
if (duration == 0)
{
return to;
}
const auto shares = caret_corner_shares(from, to); // 0.45, 0.6, 0.85 or 1.0 per corner
CaretQuad shown = to;
for (std::size_t index = 0; index < corner_count; ++index)
{
const float span = static_cast<float>(duration) * shares.at(index);
const float progress = std::min(1.0F, static_cast<float>(elapsed) / span);
const float share = eased(progress); // 1 - (1 - u)^3
const auto &start = from.corners.at(index);
const auto &end = to.corners.at(index);
shown.corners.at(index) =
CaretPoint{between(start.x, end.x, share), between(start.y, end.y, share)};
}
return shown;
}
It's a pure function. It never reads the clock: the time comes in as elapsed, measured by the Windows layer with QueryPerformanceCounter. That keeps the motion easy to test without a window.
It follows the caret wherever it goes
The caret glides whenever it actually moves: typing, arrow keys, clicks, n and *, matching brackets with %, and gg and G from one end of the file to the other. Switching between the insert bar and the Vim block caret glides too, since the four corners just head for the new shape.
When the view changes rather than the caret, as with a tab switch or a window resize, it simply jumps. Nothing moves without a reason.
Why it never makes you wait
Smooth caret animations have a bad reputation with fast typists, and fairly so: if the caret lags behind your keys, the editor feels slow. Nib avoids that in three ways.
The text doesn't wait. Your keystroke goes into the document right away. The motion is a layer drawn on top of the text. Nib doesn't rebuild any line layout for it.
A new move starts from where the caret is drawn. If you press the next key while the caret is still moving, the motion doesn't queue up and doesn't jump back. It starts again from the corners on screen and heads for the new place. Holding j or typing a word quickly stays one continuous movement.
You choose the speed. 120 ms is the default. At 40 ms the glide is barely there, just enough to see where the caret went. At 300 ms you can watch it travel across the screen.
Nothing runs when nothing moves. The animation timer runs only during a glide. Once the caret settles, it stops.
Sparks
Turn on caretsparks, and every character you type throws seven small sparks from where it lands. They fade within about 420 ms.
The colors come from your theme, so they match whichever of Nib's 125 themes you use.
A few details:
- Sparks come from characters you type. Pastes, undo,
.repeats and macro replays don't throw any, and neither do caret moves. (One exception: Japanese committed through the IME in Vim mode doesn't throw sparks either.) - There's no random number generator. Each spark's direction, speed and size come from a hash of the keystroke's sequence number, so the effect is deterministic and easy to test.
- At most eight keystrokes' worth of sparks are alive at once, so a fast burst of typing doesn't pile up.
Why it's off by default
Nib is a tool first. Some people love motion while they type, and some people find any motion distracting. So both features start off, and they stay quiet in the places where motion gets in the way:
- While the IME is composing. When you type Japanese, the composition stays still under your eyes.
- When Windows animation effects are off. If you've turned off Animation effects (Settings > Accessibility > Visual effects), Nib doesn't animate the caret or throw sparks, even with the settings on.
When they're off, all they add to the keystroke path is reading one setting, so a feature you don't use costs next to nothing.
Sources
- Design record: ADR 0192, caret motion and sparks (Japanese)
- The motion:
CaretGlide.cpp - The sparks:
CaretSparks.hpp
Try it
Get NeNe Nib on the Microsoft Store (free)
Open the settings drawer, turn on caret motion, and type a few lines. Then try 40 ms and 300 ms. Which speed did you keep?
Top comments (2)
The staggered corners are the detail that sells it — the leading corner landing at 54 ms while the back one takes the full 120 ms explains why it reads as "gliding" instead of "lagging", and it's a nice trick: the eye follows the front, so the motion feels fast even though the full travel is slow. Making caret_motion_quad a pure function that takes elapsed time as an argument is the other smart call — it keeps the motion testable without a window, which is exactly the kind of thing that rots when it's tangled into the render loop. And respecting the Windows "Animation effects" setting even when the feature is on is the kind of restraint most animation posts never mention. When you tuned the 40–300 ms range, did you find the sweet spot by feel, or did you measure anything — like how often people overshoot a target line at 300 ms versus 120 ms?
Thanks, you put it better than I did: the eye follows the front corner.
Honest answer: by feel. I watched an animated mock-up, picked 120 ms because it read as gliding rather than lagging, and kept a range around it for people who want less or more. I haven't measured overshoot.
One thing that should help there: the motion is only drawn. The caret's real position and the text move on the keystroke, and a new move starts from wherever the caret is drawn. So at 300 ms you watch a longer trip, but the next j or w doesn't wait for it. Whether people still overshoot at 300 ms because their eyes wait for the trail is a good question, and a fair test to run.