Making Kakoune Rex-aware
Files
README.md

rex.kak #

rex.kak brings Rex support to Kakoune.It provides Rex backends for interfaces Kakoune already has, plus named run panes for companion processes:

  • A windowing module, so terminal, new and focus open and focus Rex panes,
  • A REPL module, so repl-new and repl-send-text work with Rex panes, and
  • Named run panes via rex-run, for things like a test watcher next to the editor.

Because the REPL and windowing commands are Kakoune's standard ones, mappings built on them keep working outside Rex (under tmux, say) with Kakoune's own backends.

Dependencies #

rex.kak requires the rex command on your PATH. It has been tested with Rex beta builds from November 2026 (API revision 10). It uses the Lua script in rc/lua for sending text, which Rex runs with rex do. Nothing needs installing into Rex's config directory.

Installation #

Choose one of the following installation methods:

  1. Add the rc directory to your autoload directory
  2. Source rc/rex.kak manually
  3. Install via plug.kak or similar plugin managers

When loaded, rex.kak puts rex at the front of Kakoune's windowing_modules option. The module only loads when Kakoune is running inside Rex ($REX_SESSION is set), so outside Rex detection falls through to the other modules as before.

Usage #

Windowing #

These follow Kakoune's windowing module conventions, and are used by terminal according to windowing_placement:

Command Description
rex-terminal-horizontal Open a Rex pane to the right, running the given program.
rex-terminal-vertical Open a Rex pane below, running the given program.
rex-terminal-tab Open a new Rex tab, running the given program.
rex-terminal-window The same as rex-terminal-tab, since Rex's windows are its tabs.
rex-focus Focus the given client, or this client's Rex pane. Aliased to focus.

Kakoune's default windowing_placement is window, so new opens a new Rex tab. To open new clients beside the current one instead:

set-option global windowing_placement horizontal

REPL #

Command Description
rex-repl-horizontal Open a REPL pane to the right, running the given program (a shell if none), and use it for repl-send-text. Aliased to repl-new.
rex-repl-vertical As above, below the current pane.
rex-repl-window As above, in a new Rex tab.
rex-repl-set-pane Use an existing Rex pane, named by label or ID, as the REPL. Labels are completed.
rex-send-text Send the given text, or the selection, to the REPL pane. Aliased to repl-send-text.

Text is pasted into the pane as one block. A trailing newline is sent as a separate Enter, so selecting whole lines with x runs them, and REPLs with bracketed paste on behave the same way. Without a trailing newline the text is pasted but not run.

The REPL pane is stored in the rex_repl_id option at the current scope, so different windows can use different REPLs. For example:

repl-new duckdb data.db
repl-new lua
repl-new sqlite3 app.db

Named run panes #

Command Description
rex-run rex-run <label> <program> [<arguments>]: run a program in a Rex pane with the given label. If the pane exists it is closed and recreated, so running again restarts the program. The pane stays open after the program exits, and focus stays in Kakoune.
rex-rerun Repeat the last rex-run.
rex-stop Send Ctrl-C to a named pane, defaulting to the last one run.

Configuration #

Option Default Description
rex_run_split right Where rex-run places new panes: right, left, above or below.
rex_run_ratio 35 The percentage of the split that rex-run panes take.