Vim9: export an item from a script
Example
Normal 0 / 2Command-line 1 / 2Normal 2 / 2Vim9: export an item from a script.
Script runtime
- Load state
not sourced
Prepared module: limits.vim
vim9script export const LIMIT = 3
Command entered · ready to apply
Script runtime
- Load state
not sourced
Prepared module: limits.vim
vim9script export const LIMIT = 3
Command line
- Typed text
:source consumer.vim- Insertion offset
20
:export appears in the complete source file. limits.vim exports LIMIT; consumer.vim imports the module and prints limits.LIMIT.
Script runtime
- Imported namespace
limits- limits.LIMIT
3- echo output
3
Prepared module: limits.vim
vim9script export const LIMIT = 3
Before & after
Before
Script runtime
- Load state
not sourced
Prepared module: limits.vim
vim9script export const LIMIT = 3
After
Script runtime
- Imported namespace
limits- limits.LIMIT
3- echo output
3
Prepared module: limits.vim
vim9script export const LIMIT = 3
Documentation-backed illustration. Vim9 script modules; Vim's current directory contains the prepared limits.vim and consumer.vim; source code is prepared as consumer.vim. :export appears in the complete source file. limits.vim exports LIMIT; consumer.vim imports the module and prints limits.LIMIT. Primary help: :export.
vim9script
import './limits.vim' as limits
echo limits.LIMITCursor on line 1, column 1Details & Vim help
Vim9: export an item from a script. 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.