's' from Webb Miller's _A Software Tools Sampler_ is an exhaustively documented sort-of-stripped-down vi. Admittedly it's a little tricky to get your hands on the source document (I got it from interlibrary loan back at the end of the Before Times, and
archive.org lets you check it out for a limited time, but there may be a waitlist).
It's interesting in that it's not just studying the source to see how it works, but an actual (large) chapter of a book where he steps through the construction of the individual functions and their keybindings.
Adam