The mechanism
Four whole-buffer costs, each found by measuring.
None of them was the file being large. Each was the editor doing something to all of it when a screenful would have done, and each now has a rule in the source so the next change cannot quietly bring it back.
01Layout follows the viewport
Text is laid out non-contiguously: what is on screen, the caret and a scroll target are laid out for real, and everything else is estimated. Before, every keystroke and every redraw asked for the whole document to be laid out first — with word wrap on, a hundred-kilobyte line is hundreds of rows.
02Typing does not rescan the file
The table of where each line starts is updated in place from the edit itself — the characters that changed and a shift of everything after — instead of being thrown away and rebuilt from the first byte on the next key.
03Opening a second file leaves the first alone
Any preference change used to re-apply the font and the colours to every open buffer in every window, and a file joining Recent Files counts as one. Now only a change to the font, the tab width or the theme does: 982 ms became 58 ms with this file open.
04Repainting colours is linear
Clearing the old syntax colours from a region used to go token by token, each step moving the rest of the list along. It is now one replacement, which is what took a 250 KB source file from most of a second per keystroke to about a tenth.
05Colour only where you look
Files up to 256 KB are highlighted whole. Above that, the editor paints the visible lines and 200 more, and keeps the state each line starts in, so a block comment opened ten thousand lines earlier still colours correctly when you jump into the middle.
06Unsaved edits are backed up as edits
Above 64 KB, the crash backup appends what you typed to a journal instead of copying the whole buffer after every burst — until the journal grows to half the file, when one fresh copy is cheaper.