Skip to main content

Module ex

Module ex 

Source
Expand description

The ex-command NAME GRAMMAR — vim’s abbreviations, resolved in one place.

:wq is not a command name. It is a spelling of one, and vim has a whole grammar of them: every ex command has a full name, a minimum prefix that selects it, and an optional !. :w, :wr, :writ, :write are one command; :q, :qu, :quit are another; :qa and :quita are a third, and the reason :qu is not the third is that quitall’s minimum is five characters, not one.

The runtime used to carry that knowledge as three arms — "w" => "save", "q" => "quit", "u" => "undo" — and every other spelling fell through to a registry lookup that could not possibly hold it. :wq reported “command not found” while both halves of it worked.

So the grammar is a TABLE, not a chain of ifs, and the table is the only thing that knows how a typed word becomes a registered command. Two properties follow, and both are asserted rather than asserted-to:

  • Every valid abbreviation resolves. For each verb, every prefix from its minimum to its full spelling selects it (abbreviations_all_resolve).
  • No abbreviation is ambiguous. No typed word is a valid abbreviation of two verbs (no_abbreviation_is_ambiguous) — which is a property of the minimums, and the reason vim gives quitall a five-character one.

A word the grammar does not know is passed through UNCHANGED to the registry, so :noh, :picker.files and every plugin-registered command still dispatch. The grammar covers the vim vocabulary; it does not fence the command namespace.

Structs§

ExVerb
One ex command’s spelling rule.
Invocation
A parsed ex line: which command to run, and with what.

Constants§

VERBS
The vim write/quit family plus the two verbs the old three-arm table carried, with vim’s own minimum prefixes.

Functions§

parse
Parse a command line into the command to dispatch and its arguments.
resolve
The verb word spells, if any. word carries no ! and no arguments.