Vim Recall繁體中文

Prefix for an object member during initialization (e.g. on new())

:this

Example

Normal 0 / 2

Prefix for an object member during initialization (e.g. on new()).

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
pos.lnum
7; constructor assigned object member

Vim messages

7

Subject: :this. Documentation-backed illustration; assumes Vim9 class support; current unmodified buffer is saved as example.vim; not replay-verified. In the Vim9 constructor argument, this.lnum assigns the supplied 7 to the object's lnum member; :this is not a standalone command here.

Sample buffer
vim9script
class Position
  var lnum: number
  def new(this.lnum)
  enddef
endclass
var pos = Position.new(7)
echo pos.lnum
Cursor on line 1, column 1
Details & Vim help

Prefix for an object member during initialization (e.g. on new()). Supply this.member as part of a complete Vim9 constructor declaration. The index label :this names a prefix and has no standalone Ex invocation. 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.