I re-wrote ed in C once for fun:
https://github.com/tylerneylon/ed2
It uses the regex and readline libraries, as well as some container data types (array/map) called cstructs. The main C files sum to around 1,000 lines. It was an interesting exercise in learning some of the pieces of building a text editor.