Vim Recall繁體中文

Begin of an enum declaration

:enum

Example

Normal 0 / 2

Begin of an enum declaration.

Script runtime

Load state
not sourced
Before & after

Before

Script runtime

Load state
not sourced

After

Script runtime

Color
Red, Blue
echo output
Blue 1

Documentation-backed illustration. Vim 9.2 with enum support; enums occur at Vim9 script level; cmdheight=2 provides room for both echo output lines without a hit-enter prompt; source code is prepared as enum-demo.vim. :enum appears in the complete source file. The completed enum defines Blue with name Blue and zero-based ordinal 1 (Vim 9.2 Vim9-enum). Primary help: :enum.

Sample buffer
vim9script
enum Color
  Red, Blue
endenum
echo Color.Blue.name
echo Color.Blue.ordinal
Cursor on line 1, column 1
Details & Vim help

Begin of an enum declaration. This Ex reference uses the full command name; the alphabetical index omits arguments. Supply the ranges, arguments, flags and prerequisite state documented in the linked help. Press Enter to submit a complete command. Availability and exact behavior can depend on Vim build features, options, mappings and editor state; the linked help is authoritative. Vim9 script constructs require the documented Vim9 script context.