Vim Recall繁體中文

Prefix for a class or object member

:public

Example

Normal 0 / 2

Prefix for a class or object member.

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
counter.value
7; publicly writable

Vim messages

7

Subject: :public. Documentation-backed illustration; assumes Vim9 class support; current unmodified buffer is saved as example.vim; not replay-verified. Inside a sourced Vim9 class, public permits outside assignment to value; counter.value becomes 7.

Sample buffer
vim9script
class Counter
  public var value: number = 1
endclass
var counter = Counter.new()
counter.value = 7
echo counter.value
Cursor on line 1, column 1
Details & Vim help

Prefix for a class or object member. 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.