It will require you to venture into C land, but I found the walkthrough of the code for the kilo editor [0] to be very informative. It’ll hit on a number of the basic concerns that a console-based editor needs to solve. Any vi/emacs impl will obviously be a lot more complex, but a simpler starting point is better for learning.