github.com/troglobit / kg

Light Weight UTF-8 Text Editor -- Your fingers know this!

Commit log
449fac2 ⎇ masterDrop "less than 1-kilo lines" claim from sources Joachim Wiberg 47 days ago
47deac8 🏷 v1.2.0Adjust changelogs slightly Joachim Wiberg 47 days ago
cc039b9 🏷 v1.2.0-rc1Update ChangeLog and bump version for v1.2.0 release Joachim Wiberg 47 days ago
571bdb2 Split the test suite out of the top-level Makefile Joachim Wiberg 47 days ago
8a73462 doc: add visual-line-mode and local variables to the TODO Joachim Wiberg 47 days ago
b9cd4af Add several missing GNU Emacs editing commands Björn Ingvar Dahlgren 47 days ago
60a9b47 Edit the minibuffer answer with the usual Emacs keys Björn Ingvar Dahlgren 47 days ago
d599a62 Reverse-video the picker selection and elide over-long names Joachim Wiberg 48 days ago
c1fa84b Fix the fuzz build broken by the isearch rework Joachim Wiberg 48 days ago
89bb2f7 Offer to save modified buffers before quitting Joachim Wiberg 48 days ago

2 4 6

Light Weight UTF-8 Terminal Text Editor

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.

Features

  • 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

Usage

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.

Building and Installing

make
sudo make install          # installs to /usr/local/bin and /usr/local/share/man/man1

Override the prefix or use DESTDIR for staged installs:

make install prefix=/usr
make install DESTDIR=/tmp/pkg

To uninstall:

sudo make uninstall

Origin & References

kg 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.