Skip to content

feat(commands): add vim-compatible command abbreviations - #304

Merged
fcoury-oai merged 1 commit into
mainfrom
fcoury/ex-command-abbreviations
Aug 21, 2026
Merged

fcoury-oai merged 1 commit into
mainfrom
fcoury/ex-command-abbreviations

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Red currently recognizes exact Ex command names and a small set of legacy aliases, so familiar Vim abbreviations such as :ene, :sav, and :se do not work. Inferring the shortest available prefix would also make commands change meaning as Red's smaller command inventory grows.

This change gives each built-in command an explicit Vim-compatible minimum abbreviation length, rejects ambiguous or too-short prefixes, and preserves exact-command precedence, existing aliases, :wq, and plugin shadowing rules. Abbreviated :set, :syntax, and :messages commands dispatch through their canonical names, while command-name and file-argument completion retain their existing behavior.

Regression coverage checks the entire built-in inventory for duplicate names and conflicting prefixes, verifies plugin collisions, and exercises abbreviated editing, saving, splits, syntax selection, and completion. The complete library suite passed 2,119 tests with two ignored, the editing integration suite passed all 369 tests, and all-targets/all-features Clippy completed without warnings.

How to Test

  1. Open Red with an existing buffer and run :ene or :ene!. Confirm an unnamed buffer opens without saving or modifying the previous buffer; run :en and confirm it reports an unknown command without changing buffers.
  2. Run abbreviated commands such as :ed path/to/file, :wr path/to/file, :sav path/to/file, :se rnu, and :sy rust. Confirm each behaves like its full command.
  3. Type :wr and press Tab. Confirm completion still cycles between wrap and write; after typing :wr , confirm Tab completes file paths instead.
  4. Run cargo test -p red --test editing enew and cargo test -p red --lib command_palette::tests::builtin_command_prefixes_do_not_conflict. Confirm minimum-prefix handling and the complete built-in collision check both pass.

@fcoury-oai
fcoury-oai merged commit d92777c into main Aug 21, 2026
10 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/ex-command-abbreviations branch August 21, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant