Prefix for a class member or function
Example
Normal 0 / 2Command-line 1 / 2Normal 2 / 2Prefix for a class member or function.
Prepared example.vim
- Status
not sourced
Vim messages
Empty
Command entered · ready to apply
Prepared example.vim
- Status
not sourced
Vim messages
Empty
The static member belongs to the class. Both constructions increment the same total; Counter.total is 2.
Prepared example.vim
- Status
sourced- Counter.total
2; shared class member
Vim messages
2
Before & after
Before
Prepared example.vim
- Status
not sourced
Vim messages
Empty
After
Prepared example.vim
- Status
sourced- Counter.total
2; shared class member
Vim messages
2
Subject: :static. Documentation-backed illustration; assumes Vim9 class support; current unmodified buffer is saved as example.vim; not replay-verified. The static member belongs to the class. Both constructions increment the same total; Counter.total is 2.
vim9script
class Counter
static var total: number = 0
def new()
total += 1
enddef
endclass
var a = Counter.new()
var b = Counter.new()
echo Counter.totalCursor on line 1, column 1Details & Vim help
Prefix for a class member or function. 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.