Skip to main content

Module keymap_help

Module keymap_help 

Source
Expand description

K.3.2 (2026-06-02): help-prefix (<C-h> map) bindings.

Emacs-style discoverability for the §5.11 self-documenting help facility. From any Normal-mode buffer, <C-h> is a prefix that opens the help workflow:

ChordCommandWhat it does
<C-h> <C-h>:help-for-helpOpen help index.
<C-h> ?:help-for-helpAlias — easier to type.
<C-h> k:describe-keyPrompt for chord, show binding.
<C-h> c:describe-commandPrompt for command name.
<C-h> o:describe-optionPrompt for option name.
<C-h> e:describe-eventPrompt for typed-event name.
<C-h> f:describe-elementPrompt for theme element / face name.
<C-h> m:describe-active-modesActive major + minors on this buffer, with their chords.
<C-h> M:describe-modePrompt for a mode name; show that mode’s metadata.
<C-h> b:describe-bufferBuffer metadata (kind, flags, modes, …).
<C-h> a:aproposCross-cutting search.
<C-h> K:describe-bindingsChords that can fire on this buffer. :keymap remains the full catalog.

§DAM.4 correction (2026-08-04)

K.3.2 bound <C-h>m to :describe-mode, whose name arg is ArgDefault::Required — so the no-arg invocation armed the interactive mode: prompt and asked which mode to describe. It never showed the active modes, though this table, the HelpPrefixEntry doc, and keymap-architecture §12.1 all said it did. <C-h>m now routes to :describe-active-modes; <C-h>M keeps the prompt-for-any-mode path that <C-h>m was accidentally providing, so nothing is lost.

The m / M pair reads listing-then-specific while the older k / K pair reads specific-then-listing. Deliberate: lowercase is the common case in both, and C-h m = active modes is the emacs muscle memory worth preserving.

§Design choices (per K.3 slice plan)

  • No bare <C-h> leaf. K.3.0’s trie audit found that today’s matcher returns Bound immediately when a node carries a binding, even if it also has children — and the dispatcher has no timeoutlen machinery to wait for a follow-on chord. Vim’s “leaf + prefix” ambiguity needs timer-driven dispatch which isn’t worth introducing for a single help affordance. Instead, <C-h> is a pure prefix node (returns Partial), and the slice plan’s listed alternative <C-h><C-h> (plus the easier-to-type <C-h>?) is the explicit help-for-help entry. One keystroke of extra friction; zero new infrastructure.
  • Normal mode only. Insert / Visual / OperatorPending / Cmdline retain their existing <C-h> semantics (Insert keeps backspace; cmdline keeps cmdline-backspace). The K.1.c per-keystroke filter naturally enforces this because bindings are registered with BindingMode::Normal; other modes simply don’t match.
  • KeymapLayer::Builtin. Universal availability across every Normal-mode buffer — same shape as Normal-mode motions, operators, and the rest of the vim default catalog. The mode-architecture §13 convention (“feature- gated bindings live at MinorMode”) doesn’t apply here because the help prefix isn’t feature-gated; it’s a universal discoverability affordance.

Functions§

register_help_prefix_bindings
Register the <C-h> help-prefix bindings into the supplied handle’s Builtin layer at BindingMode::Normal.