Begin of a class declaration
Example
Normal 0 / 2Command-line 1 / 2Normal 2 / 2Begin of a class declaration.
Script runtime
- Load state
not sourced
Command entered · ready to apply
Script runtime
- Load state
not sourced
Command line
- Typed text
:source point-demo.vim- Insertion offset
22
:class appears in the complete source file. The class block defines Point; its default constructor creates p with x=3.
Script runtime
- Defined class
Point- p.x
3- echo output
3
Before & after
Before
Script runtime
- Load state
not sourced
After
Script runtime
- Defined class
Point- p.x
3- echo output
3
Documentation-backed illustration. Vim9 class support (+eval); class declarations occur only at script level; source code is prepared as point-demo.vim. :class appears in the complete source file. The class block defines Point; its default constructor creates p with x=3. Primary help: :class.
vim9script
class Point
var x: number = 3
endclass
var p = Point.new()
echo p.xCursor on line 1, column 1Details & Vim help
Begin of a class 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.