Had an assignment in functional programming which was to implement a text editor, an interesting data structure was provided.
Buffer of X is a BackwardsList of X, Cursor X, ForwardsList of X
So if you make Line a Buffer of char and your document a Buffer of Line you can easily insert and remove characters on a line or lines in the document.
If you wanted to move the cursor forwards you could just place the cursor onto the head of the backwards list behind you and take the head off the forwards list in front of you to be your cursor.