A spiritual descendant of mg (Micro Emacs) — same Emacs heritage, about half the lines of code. See mg's README for the wider Emacs-in-a-terminal family kg comes from.
kg is a small, fast terminal text editor with pure Emacs keybindings. Suitable for editing system files or quick fixes on remote systems where a full GUI editor is not available.
With syntax highlighting for many languages, multiple buffers, split windows, incremental search, and multi-level undo, kg punches above its weight while staying dependency-free — no curses, just standard VT100 escape sequences.
- Pure Emacs-style keybindings
- Syntax highlighting for many programming languages, including hex/binary/octal integer literals
- Multiple buffers with shared kill ring
- Split-window support
- Visual mark mode: the region renders in reverse video as you move
- Shift-select and the CUA clipboard trio (Shift-Delete / Ctrl-Insert / Shift-Insert) alongside the Emacs C-w / M-w / C-y
- Rectangle commands (C-x SPC, C-x r {k,y,d,c})
- Incremental search and query-replace (M-%)
- Multi-level undo (C-_)
- Paragraph reflow to 72 columns (M-q)
- Keyboard macros (C-x ( / C-x ) / C-x e)
- M-x, C-x C-f, and C-x b all share an ido-style picker: substring matching, already-open files pushed to the back of the file picker
- Detects external changes to open files; optional auto-revert
- Shell commands (M-!) and pipe-region-through-command (M-|)
- Comment-dwim (M-;)
- Word-case bindings (M-u / M-l / M-c)
- Open line (C-o) and join-line (M-^)
- Quoted-insert (C-q) for literal Tab/Esc/control bytes
- Universal-argument (C-u) for repeated commands
- Auto-indent and bracket autocomplete
- Suspend to background (C-z)
- Built-in help in a scrollable help buffer (C-h)
- No dependencies (not even curses)
- Uses standard VT100 escape sequences
- Graceful terminal resize handling
kg [-RVh] [file ...]
| Option | Description |
|---|---|
-R |
Open file(s) read-only |
-V |
Print version and exit |
-h |
Print this help and exit |
Multiple files can be opened at once, each in its own buffer. See the man page for more in-depth information as well as the full key binding reference.
make
sudo make install # installs to /usr/local/bin and /usr/local/share/man/man1Override the prefix or use DESTDIR for staged installs:
make install prefix=/usr
make install DESTDIR=/tmp/pkgTo uninstall:
sudo make uninstallkg is based on kilo by Salvatore Sanfilippo (antirez), the original minimal text editor that demonstrates how to build a functional editor without dependencies in about 1000 lines of C code.
The name "kg" is a nod to mg (Micro Emacs), suggesting "kilo-gram" — a minimal implementation with Emacs keybindings. mg's README is the place to read up on the broader lineage if the heritage matters to you.

