Vim Recall繁體中文

Compile Vim9 functions in the current script, or a named function

:defcompile

Example

Normal 0 / 2

Compile Vim9 functions in the current script, or a named function.

Loaded Vim9 function

vim9script
def g:Twice(n: number): number
  return n * 2
enddef
g:Twice
defined; not compiled
Source file
typed-twice.vim
Before & after

Before

Loaded Vim9 function

vim9script
def g:Twice(n: number): number
  return n * 2
enddef
g:Twice
defined; not compiled
Source file
typed-twice.vim

After

Loaded Vim9 function

vim9script
def g:Twice(n: number): number
  return n * 2
enddef
g:Twice
compiled successfully; no diagnostic
Source file
typed-twice.vim

Documentation-backed illustration. Vim9 support; typed-twice.vim was sourced and g:Twice has not yet been compiled. :defcompile checks and compiles g:Twice without calling it. Primary help: :defcompile.

Sample buffer
vim9script
def g:Twice(n: number): number
  return n * 2
enddef
Cursor on line 1, column 1
Details & Vim help

Compile Vim9 functions in the current script, or a named 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. The index spelling :defc[ompile] puts the optional abbreviation suffix in square brackets; those brackets are not typed. 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.