Compile Vim9 functions in the current script, or a named function
Example
Normal 0 / 2Command-line 1 / 2Normal 2 / 2Compile 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
Command entered · ready to apply
Loaded Vim9 function
vim9script def g:Twice(n: number): number return n * 2 enddef
- g:Twice
defined; not compiled- Source file
typed-twice.vim
Command line
- Typed text
:defcompile g:Twice- Insertion offset
19
:defcompile checks and compiles g:Twice without calling it.
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
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.
vim9script
def g:Twice(n: number): number
return n * 2
enddefCursor on line 1, column 1Details & 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.