In my quest to write a programmable editor the first problem that i came across was which datastructure to hold the text in? What do other text editors use? For instance emacs in which this blog is written uses gap buffer. Gap buffer the a linear array with two extra empty spaces in the array. Let me demonstrate how a gap buffer looks like.