Below are some examples of operations with buffer gaps. The gap is represented by the empty space between the square brackets. This representation is a bit misleading: in a typical implementation, the endpoints of the gap are tracked using pointers or array indices, and the contents of the gap are ignored; this allows, for example, deletions to be done by adjusting a pointer without changing the text in the buffer.
Initial state:
User inserts some new text:
User moves the cursor before "started"; system moves "started " from the first buffer to the second buffer.
User adds text filling the gap; system creates new gap:
Mark C. Chu-Carroll. "Gap Buffers, or, Don’t Get Tied Up With Ropes?" ScienceBlogs, 2009-02-18. Accessed 2013-01-30. http://scienceblogs.com/goodmath/2009/02/18/gap-buffers-or-why-bother-with-1/ ↩
emacs gap buffer info Accessed 2013-01-30. https://www.gnu.org/software/emacs/manual/html_node/elisp/Buffer-Gap.html ↩