Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

use a gap buffer: https://en.wikipedia.org/wiki/Gap_buffer.

For scaling large docs, you can do a linked list of gap buffers and avoid re-allocs of large buffers.

Super simple, efficient enough for most “i wrote my own text editor”, can always plug in a more complex structure later.

Author’s implementation will drag down if you have very long lines (e.g., transpiled JS).



Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: