Declare a Vim9 abstract class
Example
Normal 0 / 2Command-line 1 / 2Normal 2 / 2Declare a Vim9 abstract class.
Script runtime
- Load state
not sourced
Command entered · ready to apply
Script runtime
- Load state
not sourced
Command line
- Typed text
:source abstract-demo.vim- Insertion offset
25
:abstract appears in the complete source file. The abstract Area contract is implemented by Unit, whose Area() returns 1.
Script runtime
- Shape
abstract class; no direct instances- Unit
concrete subclass implementing Area- echo output
1
Before & after
Before
Script runtime
- Load state
not sourced
After
Script runtime
- Shape
abstract class; no direct instances- Unit
concrete subclass implementing Area- echo output
1
Documentation-backed illustration. Vim9 class and abstract-method support at script level; source code is prepared as abstract-demo.vim. :abstract appears in the complete source file. The abstract Area contract is implemented by Unit, whose Area() returns 1. Primary help: :abstract.
vim9script
abstract class Shape
abstract def Area(): number
endclass
class Unit extends Shape
def Area(): number
return 1
enddef
endclass
var u = Unit.new()
echo u.Area()Cursor on line 1, column 1Details & Vim help
Declare a Vim9 abstract class. 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.