The 2025 Wheel Reinvention Jam just concluded. See the results.
This is a single-header C library which implements a code editor.

About Editor.h


This is a single-header C library which implements a code editor. Is it faster, smaller, more powerful, or more innovative than existing code editors? No. Its main selling point is it is a single C header file with zero includes. You need to bring your own typesetting, input, and rendering, which means there is some up-front integration work, but it will integrate wherever you want it. If you e.g. already have your own immediate-mode UI but you want more powerful text editing, this project is a good way to add that in.

It takes the most innovative features from Sublime Text (multiple cursors) and combines them with some innovations from Emacs (selective undo, lazy proximity autocomplete, smart indentation, incremental search). It implements all the most fundamental cursor motion and deletion (by character, by word, beginning/end of line), and adds some power user motions from Emacs and Sublime (move up/down blocks, kill lines, create line above/below).

It supports variable-width fonts (hi Felix) and I intend to also support rich text, i.e., different fonts on the same line.

It uses blocks of linear allocations for memory, which makes it amenable to very simple host memory management schemes, e.g. a page allocator.

For those of you suffering from the Vim curse, it is possible to add modal editing to this editor. I will not do it for you though, and I'm not really interested in getting code from you that does it either. I'd recommend you make an EditorModal.h and upload it where you will. It would need to retain my original copyright and license, and then you can add your own copyright for your modifications.

I have specifically avoided spending any time on sinks like syntax highlighting or default keybindings, as these tend to be highly opinionated (which languages to support or what keybindings should be). Instead, the "host" (the user of the library) must handle e.g. setting all the default bindings to their liking. By doing so, Editor.h does not define any enumeration for key codes, which means you can use whatever you already use for those without needing a new mapping.

How does it compare to stb_textedit.h? Editor.h implements word wrapping, unlimited undo, can handle larger texts (long source files; don't bother using it for multi-megabyte log files though), and has modern editing features like multiple cursors. Editor.h is also intended to support built-in window splitting and multiple buffer editing. While still a work in progress, Editor.h intends to use UTF-8 as the native encoding. Editor.h does more than stb_textedit.h, for better and for worse. It would be wise to read both Editor.h and stb_textedit.h to decide which is best for your application.

Read more
Filters

Recent Activity

am currently on vacation and cannot update or add more information until early October. I did the work on this the first week of September because I knew I would be busy the actual jam week.