Vim Recall繁體中文

Begin of an interface declaration

:interface

Example

Normal 0 / 2

Begin of an interface declaration.

Script runtime

Load state
not sourced
Before & after

Before

Script runtime

Load state
not sourced

After

Script runtime

HasSize
interface requiring Size(): number
Unit
implements HasSize
echo output
1

Documentation-backed illustration. Vim9 interface support at script level; source code is prepared as interface-demo.vim. :interface appears in the complete source file. The interface contains a signature without a body/enddef; Unit supplies the implementation. Primary help: :interface.

Sample buffer
vim9script
interface HasSize
  def Size(): number
endinterface
class Unit implements HasSize
  def Size(): number
    return 1
  enddef
endclass
var u = Unit.new()
echo u.Size()
Cursor on line 1, column 1
Details & Vim help

Begin of an interface 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.