Changes
-
Point-editing commands from GNU Emacs: C-t transpose-chars, M-h mark-paragraph, M-z zap-to-char, M-\ delete-horizontal-space, M-SPC just-one-space, and M-digit as a numeric prefix alongside C-u. Each editing command is also available as an M-x alias. From Björn Dahlgren's fork.
-
Per-buffer fill column, set with C-x f (set-fill-column). M-q reflow was fixed at 72 columns; the width is now a per-buffer setting, defaulting to 72 and seeded with the current value when C-x f prompts, and it rides along with the buffer across switches like auto-revert does.
-
The minibuffer answer can be edited with the usual Emacs keys -- C-a/C-e, C-b/C-f, C-d, C-k, Home/End and the arrows -- and C-q inserts the next keystroke literally. From Björn Dahlgren's fork.
-
The M-x, buffer, and file pickers highlight the selected candidate in reverse video instead of braces and bold, and a candidate too long for the line keeps its start and end visible with an elided middle -- so arrowing through long, similar names no longer looks stuck.
-
Killing the last buffer with C-x k drops to an empty scratch buffer instead of quitting kg, like GNU Emacs.
-
Quitting with C-x C-c offers to save each modified buffer first, like GNU Emacs, and asks to confirm the exit only if any are left unsaved -- rather than discarding every unsaved change at once.
-
M-x sort-lines sorts the lines the region covers into byte order -- like sort(1) in the C locale, so case-sensitive and not numeric -- as a single undo step. From Björn Dahlgren's fork.
-
M-x read-only-mode toggles a buffer read-only, alongside C-x C-q and M-x toggle-read-only. A read-only buffer now refuses every buffer-modifying command, by keystroke or by M-x alike, enforced at the point of mutation so editing keys like M-u, M-^, and C-o can no longer slip through. The mode line marks a read-only buffer with
%%, or%*when it has unsaved changes, like GNU Emacs. The read-only-mode command is from Björn Dahlgren's fork. -
Opening a file without write permission now enters read-only mode, like GNU Emacs, so a file you cannot save back is flagged up front instead of only at save time.
-
Saving is atomic. The new contents go to a temporary file beside the target, which is fsync'd and renamed over it, so an interrupted or failed write can no longer truncate the file -- a reader sees either the old file or the complete new one. The file's mode and owner are preserved, and a symlinked target is replaced in place. From Björn Dahlgren's fork.
-
Saving keeps the previous version as a
foo~backup, like GNU Emacs. The first save of a session renames the file being replaced tofoo~before writing the new contents, so a fat-fingered edit or an accidental deletion is onemv foo~ fooaway. Turn it off with M-x make-backup-files. -
M-x require-final-newline makes saving add a trailing newline to a file that lacks one, giving the buffer the empty last line like GNU Emacs. Off by default, so a file without a final newline still round-trips untouched unless you ask for one.
-
Incremental search behaves more like GNU Emacs. The view holds still while the match is on screen and only recentres once it scrolls off, instead of yanking every hit to the top of the window. A motion key pressed mid-search (C-a, C-f, M-f, M-<, ...) ends the search and runs, leaving point on the match — at its end searching forward, its start searching back — and C-Space ends the search with the mark set there. C-r now searches backward from point rather than always scanning forward from the top. From Björn Dahlgren's fork.
-
Incremental search and query-replace fold case for an all-lowercase query and match exactly once the query contains an uppercase letter, like GNU Emacs. From Björn Dahlgren's fork.
-
Files round-trip byte for byte. A file without a final newline keeps it that way through a save, and a file ending in a newline shows a trailing empty line, like GNU Emacs; kg no longer forces a trailing newline onto a file that had none. From Björn Dahlgren's fork.
-
Lines past the end of the buffer traditionally carrying a leading "~", this can now be disabled at build-time, to make kg resemble GNU Emacs. Build with
make KG_SHOW_TILDE=0to disable. From Björn Dahlgren's fork. -
kg now runs on the terminal's alternate screen, like other full-screen editors: the shell's content and scrollback come back intact on exit and suspend. This is also what makes VTE-based terminals (gnome-terminal and friends) deliver shift-modified arrow keys to the editor instead of scrolling the scrollback.
-
C-x 2 and C-x 3 now split only the current window, like in GNU Emacs: C-x 2 into an upper and a lower half, C-x 3 into a left and a right half. Other windows are not disturbed, so stacked and side-by-side layouts mix freely. C-x 0 gives the closed window's space to the neighbors sharing its edge.
-
Shift-select by word and paragraph. Ctrl+Shift+left/right extends the region one word at a time, Ctrl+Shift+up/down one paragraph, Shift+PgUp/PgDn one page, and Ctrl+Shift+Home/End to the buffer ends, complementing the character/line steps from v1.1. The same transient-mark rules apply: the first unshifted key drops the region, and an explicit C-Space mark stays sticky. Word motion (M-f, C-right, and the shifted variant) now lands at the end of the word, like in GNU Emacs and Mg, instead of at the start of the next one, and crosses line boundaries the way backward-word already did.
As with the CUA clipboard keys in v1.1, some terminals grab these combos for themselves: Terminator resizes its panes with Ctrl+Shift+arrows and moves between them with Alt+arrows, KiTTY reserves Ctrl+Shift for its own shortcuts, and Gnome Terminal switches tabs on Ctrl+PgUp/PgDn. Free the keys in the terminal preferences to use them in kg; see kg(1) for details.
-
Move between windows with Meta and the arrow keys, like windmove in GNU Emacs: M-arrow selects the neighbor in that direction, quicker than lapping the C-x o ring in a three-window layout. Also available as M-x windmove-up/-down/-left/-right.
-
Resize windows with Meta, Shift and the arrow keys: the divider on that side of the window travels with the arrow, and C-u N moves it N rows or columns at once. The GNU Emacs commands are wired up alongside: enlarge-window (C-x ^), enlarge-window-horizontally and shrink-window-horizontally (C-x } and C-x {), and balance-windows (C-x +). A terminal resize goes to the focused window; the other windows keep their size and move.
-
Ctrl+PgUp and Ctrl+PgDn move to the beginning and end of the buffer, like C-Home and C-End.
-
F1 opens the built-in help (like C-h), F2 saves (C-x C-s), and F10 quits (C-x C-c), rounding out the function-key row alongside the F3/F4 macro keys.
-
Home and End are now recognised from VT220 and rxvt terminals, which send the numbered forms (ESC[1~/ESC[4~ and ESC[7~/ESC[8~) rather than the usual sequences. From Björn Dahlgren's fork.
Fixes
-
UTF-8 text no longer renders as inverted garbage in buffers with a language mode: the highlighter classified every multibyte character as non-printable. Most visible as broken box-drawing characters when reopening the built-in help (C-h C-h).
-
M-; (comment-dwim) on a region no longer comments its last line when the region ends at that line's column 0, matching Emacs' comment-region: a region from the start of line N to the start of line N+2 now comments only N and N+1. From Björn Dahlgren's fork.
-
Undo of a line join restores an empty line again. Backspacing at the start of a blank line and then undoing used to drop the blank line, because the undo record carried no text for the zero-length line.
-
A batch of crash and memory-safety fixes surfaced by the new keypress fuzz harness: out-of-bounds cursor and edit handling when point sat past a short line or the buffer shrank underneath it, a SIGWINCH handler that ran unsafe work (malloc, write) mid-signal and could corrupt the heap during a resize, and a memset() on the NULL highlight buffer of an empty row.
Bug Fixes
- Fix
qquitting the editor when typed in a lone*scratch*buffer;qnow only closes special buffers when another buffer is available