Vim Recall繁體中文

Create a type alias

:type

Example

Normal 0 / 2

Create a type alias.

Prepared example.vim

Status
not sourced

Vim messages

Empty
Before & after

Before

Prepared example.vim

Status
not sourced

Vim messages

Empty

After

Prepared example.vim

Status
sourced
Names
alias of list<string>
names
['Ada', 'Lin']

Vim messages

Ada

Subject: :type. Documentation-backed illustration; assumes Vim9 type-alias support; alias is at script level and starts uppercase; current unmodified buffer is saved as example.vim; not replay-verified. The script-level type alias Names denotes list<string>; names is initialized with that type and names[0] is Ada.

Sample buffer
vim9script
type Names = list<string>
var names: Names = ['Ada', 'Lin']
echo names[0]
Cursor on line 1, column 1
Details & Vim help

Create a type alias. 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.